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

can't pass 0 for clientMaxAge #22

Open
spollack opened this issue Jan 29, 2012 · 8 comments · May be fixed by #49
Open

can't pass 0 for clientMaxAge #22

spollack opened this issue Jan 29, 2012 · 8 comments · May be fixed by #49

Comments

@spollack
Copy link

If i try to pass the value 0 for clientMaxAge, it instead gets the default value. Looks like a logic issue where the clientMaxAge variable is set up.

@tomgco
Copy link
Owner

tomgco commented Jan 31, 2012

Hi,

This happens because 0 gets interpreted as false by: clientMaxAge = options.clientMaxAge || 604800000, which then returns the default value as you said.

I am not sure why you would want to set this to 0... Let me know your reasonings and I could possibly implement a fix...

@spollack
Copy link
Author

Sure. Its not uncommon to set the max-age to 0 for cached content. This means that the cache must validate with the server before serving the cached response, as it is already stale. Useful for cases where you want content changes to propagate quickly, but still want to leverage caching so that the network traffic is reduced from doing a full GET to just doing an If-Modified-Since or similar validity check for the common case.

@tomgco
Copy link
Owner

tomgco commented Jan 31, 2012

Makes sense, I am currently working on a major refactor, so this will be fixed in it.

@spollack
Copy link
Author

great, thanks Tom.

Btw, here are a few resources i've found useful on this topic of HTTP caching:
http://www.mnot.net/cache_docs/ -- good description of how things work
http://redbot.org/ -- great way to test if you are sending the right HTTP headers or not, and understand what they mean

@spollack
Copy link
Author

A wishlist item here would be also supporting ETag validation as well, to see if content has changed.

@tomgco
Copy link
Owner

tomgco commented Feb 11, 2012

Sounds good, I will look into it.

@spollack
Copy link
Author

Great, thanks!

awwx added a commit to awwx/gzippo that referenced this issue Jan 23, 2013
@awwx awwx linked a pull request Jan 23, 2013 that will close this issue
@mitar
Copy link

mitar commented Feb 12, 2013

+1

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 a pull request may close this issue.

3 participants