gzippo icon indicating copy to clipboard operation
gzippo copied to clipboard

can't pass 0 for clientMaxAge

Open spollack opened this issue 13 years ago • 8 comments

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.

spollack avatar Jan 29 '12 23:01 spollack

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...

tomgco avatar Jan 31 '12 00:01 tomgco

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.

spollack avatar Jan 31 '12 01:01 spollack

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

tomgco avatar Jan 31 '12 14:01 tomgco

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 avatar Jan 31 '12 14:01 spollack

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

spollack avatar Feb 11 '12 00:02 spollack

Sounds good, I will look into it.

tomgco avatar Feb 11 '12 13:02 tomgco

Great, thanks!

spollack avatar Feb 11 '12 20:02 spollack

+1

mitar avatar Feb 12 '13 07:02 mitar