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

express.static - add support for cache-control: immutable #3197

Closed
techandsoftware opened this issue Feb 3, 2017 · 3 comments
Closed

express.static - add support for cache-control: immutable #3197

techandsoftware opened this issue Feb 3, 2017 · 3 comments

Comments

@techandsoftware
Copy link

techandsoftware commented Feb 3, 2017

On static content with versioned URLs, add a flag to options on express.static that generates a cache-control header with immutable, e.g.:
Cache-Control: max-age=365000000, immutable
This reduces unnecessary requests in supporting clients.

This is supported by Firefox 49 and used by Facebook:
https://hacks.mozilla.org/2017/01/using-immutable-caching-to-speed-up-the-web/
https://bitsup.blogspot.co.uk/2016/05/cache-control-immutable.html

Supported in Chrome 54
https://bugs.chromium.org/p/chromium/issues/detail?id=611416

Webkit support seems to be added:
https://bugs.webkit.org/show_bug.cgi?id=167497

@dougwilson dougwilson self-assigned this Feb 5, 2017
@dougwilson
Copy link
Contributor

Sounds reasonable :) One point missed above is that Chrome does not support this, as you can read through in that Chromium issue (they implement something similar to cache-control: immutable using heuristics instead of looking at a header value at all).

Thinking how we could easily add this to our API, what about having it where if you set maxAge: Infinity it would add the immutable tag in addition to the 1 year age it does today?

@techandsoftware
Copy link
Author

Ok, I confess I didn't read all the comments. The maxAge: Infinity suggestion sounds good.

@dougwilson
Copy link
Contributor

This landed in the upstream send dependency, so will be part of the Express.js 4.16 release.

@dougwilson dougwilson mentioned this issue Sep 28, 2017
20 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants