Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting uncached mode to work #10

Merged
merged 5 commits into from Aug 16, 2011
Merged

Getting uncached mode to work #10

merged 5 commits into from Aug 16, 2011

Conversation

arsduo
Copy link
Contributor

@arsduo arsduo commented Jun 1, 2011

Right now, Rack::Offline offers an uncached mode in which the manifest is constantly regenerated; it's a great idea for development (and is on by default in dev environment), but doesn't actually work. The problem is that the cache-breaking comment in the manifest is generated by the following line:

Digest::SHA2.hexdigest(Time.now.to_s + Time.now.usec.to_s)

Since the browser downloads the cache twice (once at the beginning, and once at the end for verification), the use of usec means the manifest will always be different and the app cache can never be built.

I've written a patch (with tests) to change this behavior; with these changes, the comment will only change after a configurable interval (by default 10 seconds) to allow the browser to download the cache first. (There's always a risk that the download will start too close to the boundary, but since this is development only, the developer can adjust the interval to his or her preference.)

PS thanks for the very useful gem! I remember hearing about it in a side talk at the jQuery conference last year in Mountain View, and am very excited to finally be using it.

@tosswill
Copy link

tosswill commented Aug 9, 2011

works for me.

wycats added a commit that referenced this pull request Aug 16, 2011
Getting uncached mode to work
@wycats wycats merged commit 77d1140 into wycats:master Aug 16, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants