Cache-Control: immutable

caching

#1

We’d like our assets to return “immutable” property in cache-control header. Then it might be used by some browsers to mark assets that are not changed at all (Firefox, Edge and Safari, according to https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control#Browser_compatibility)

I am aware that this has no influence on Cloudflare itself, but Cloudflare could just forward it to browsers - now it seems, that it’s removed.


#2

Seems to get passed through

< snip >


#3

I’m not able to go to cachecontrol.php as it redirects to main page and I can’t see any asset there returning with “immutable”…


#4

You need to check the headers you receive, there’s “Cache-Control”


#5

I see them. There’s for example " Cache-Control: public, max-age=14400"
No “immutable” added


#6

Can you post a screenshot? I clearly have the header here.


#7

OK, now I can see it being set for cachecontrol.php document. We are trying to set it for JS/CSS assets and unluckily it’s not being passed…


#8

In that case it’s likely the server does not set them properly for those assets. I’d double check that.


#9

We’ve got it set on our QA environment, which is not using Cloudflare and it’s returned like: " Cache-Control: public,immutable,max-age=31536000"
Then on our staging with Cloudflare, it’s stripped of “immutable”


#10

I’d double check it on staging too :wink:

Maybe Cloudflare strips something, from the test above it would seem they dont but who knows :smiley:


#11

Appreciate your help on this :slight_smile:
From official support I’ve got the response, that CF doesn’t support immutable, but I don’t know why would it be like that, as this is only to pass this header forward…
So I’m looking here if someone has any experience with this header.


#12

Just tried it with a cacheable resource (PNG) and it does seem as if Cloudflare stripped it under certain circumstances. If you turn on development mode it gets passed through, but the moment the cache is involved it seems it is being stripped.

Maybe @cscharff or @cloonan have more insight.


#15

@damian.szewczyk Another approach could be to set up a page rule which disables caching for the file in question. Once Cloudflare’s cache is not involved the header goes through.


#16

@sandro thank you for your tips. Unluckily we’re not controlling our Cloudflare integration… Also we’d rather not skip Cloudflare cache and control each file independently…

@cscharff @andy @ryan @harris @cloonan @Ricardo @zack @hasan
Any answer to this from Cloudflare team maybe? Is there a reason why “Cache-control: immutable” is not passed further? It could limit traffic from browsers, that implemented it (they will not try to revalidate the files marked as “immutable”).


#17

Assuming they are in a common directory it should be sufficient to configure that directory.


#18

I’ve set up my own Cloudflare integration and together with support found out how it should be configured.

Looks like by default max-age property is honored and passed by Cloudflare, but to have other fields from Cache-Control, Page Rule “Origin Cache Control” needs to be turned on


#19

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.