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

consider setting cache-control:immutable #8655

Open
kralo opened this issue Aug 2, 2016 · 14 comments
Open

consider setting cache-control:immutable #8655

kralo opened this issue Aug 2, 2016 · 14 comments

Comments

@kralo
Copy link

kralo commented Aug 2, 2016

which is a cache-control extension implemented already in firefox. I think this is reasonable, as you already set a large cache expiration date Cache-Control: public, max-age=30672000

This could help reducing calls to the server resulting in 304 not-modified and thereby also reduce some privacy issues (less requests - less traceability)...


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@drewfreyling
Copy link
Member

This is a good idea but might not be of real benefit until it is supported by more browsers as it is just a bunch of wasted bytes unless you use a recent version of Firefox.
Chrome doesn't seem to be in a hurry - https://bugs.chromium.org/p/chromium/issues/detail?id=611416

@PeterDaveHello
Copy link
Contributor

cc @cdnjs/owners @terinjokes

@terinjokes
Copy link
Contributor

This looks pretty cool.

I don't think we should implement it until I change the backend to reduce the update failures we have from time to time (and, perhaps, officially supporting "latest")

@dima74
Copy link

dima74 commented May 1, 2017

Hello! What about adding Cache-Control: immutable only when user-agent is Firefox?

@PeterDaveHello
Copy link
Contributor

Hi @terinjokes, I think it'll be great to enable it no matter it the backend on Cloudflare side changes as this can really help improve performance by reducing the cache validation, am I right?

@MattIPv4
Copy link
Member

MattIPv4 commented Mar 2, 2019

@PeterDaveHello Chrome still does not have this implemented, should I raise this to Cf to ask them to set Cache control to be immutable when a Firefox UA is detected?

@MatthewSteeples
Copy link

Everyone apart from Chrome (and probable IE) implement this now

@MattIPv4 MattIPv4 self-assigned this Apr 25, 2019
@MattIPv4
Copy link
Member

@MatthewSteeples Yeah, I think it best we implement it as it should improve performance. I will contact Cf and post any updates here :)

@MattIPv4
Copy link
Member

MattIPv4 commented Apr 6, 2020

@xtuc would you be able to help with getting this added?

@MattIPv4 MattIPv4 assigned xtuc and unassigned dknecht Apr 6, 2020
@xtuc
Copy link
Member

xtuc commented Apr 6, 2020

According to https://caniuse.com/#feat=mdn-http_headers_cache-control_immutable the support is pretty low

@MattIPv4
Copy link
Member

MattIPv4 commented Apr 6, 2020

Currently, we send cache-control: public, max-age=30672000. Looking at https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#Caching_static_assets it should be safe to append , immutable.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#Extension_Cache-Control_directives notes that if a UA doesn't recognize immutable, it should just be ignored, so it'd fall back to the long max-age we are sending.

(I'm no expert on this though)

@xtuc
Copy link
Member

xtuc commented Apr 6, 2020

@MattIPv4 that sound right. I sent the header to my Chrome and it didn't fail. That said, I'm not sure how to check that it works

@MattIPv4
Copy link
Member

MattIPv4 commented Apr 6, 2020

@xtuc Simple. Just wait a year and see if it expires. /s

@MattIPv4
Copy link
Member

MattIPv4 commented Apr 6, 2020

Chrome's dev tools should show if the resource was fetched from cache or not, but I'm not sure of any way to really confirm how long it's planning to hold the resource for in cache.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

9 participants