Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any reason not to add "Cache-Control: no-transform" header to every page?

Tags:

We have recently fixed a nagging error on our website similar to the one described in How to stop javascript injection from vodafone proxy? - basically, the Vodafone mobile network was vandalizing our pages in transit, making edits to the JavaScript which broke viewmodels.

Adding a "Cache-Control: no-transform" header to the page that was experiencing the problem fixed it, which is great.

However, we are concerned that as we do more client-side development using JavaScript MVP techniques, we may see it again.

Is there any reason not to add this header to every page served up by our site?

Are there any useful transformations that this will prevent? Or is it basically just similar examples of carriers making ham-fisted attempts to minify things and potentially breaking them in the process?

like image 894
Carson63000 Avatar asked Nov 21 '13 23:11

Carson63000


People also ask

What happens if you don't set cache-control header?

Without the cache control header the browser requests the resource every time it loads a new(?) page.

What is the key drawback of cache-control?

Cache-control: no-transform This can cause problems if the asset is to remain identical to the original entity-body. The no-transform directive tells the intermediate caches or proxies not to make any such modifications. For example, they cannot edit the response body, Content-Encoding, Content-Range, or Content-Type.

What should add to a cache-control header?

private. The private response directive indicates that the response can be stored only in a private cache (e.g. local caches in browsers). You should add the private directive for user-personalized content, especially for responses received after login and for sessions managed via cookies.

Which header is not used in cache management?

The expires header is ignored when a cache-control header containing a max-age directive is present.


2 Answers

The reasons not to add this header is speed performance and data transfer.

Some proxy / CDN services encode the media, so if your client is behind proxy or are you using a CDN service, the client may get higher speed and spend littler data transfer. This header actually orders proxy / CDN - not to encode the media , and leave the data as is.

So, if you don't care about this, or your app not use many files like images or music, or you don't want any encoding on your traffic, there is no reason not to do this (and the opposite, recommended to).

See the RFC here: http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9.5

like image 118
MeNa Avatar answered Sep 23 '22 03:09

MeNa


Google has recently incorporated the service googleweblight so if your pages has the "Cache-Control: no-transform" header directive you'll be opting-out from transcoding your page in case the connection comes from a mobile device with slow internet connection.

More info here: https://support.google.com/webmasters/answer/6211428?hl=en

like image 25
Marta Garcia Avatar answered Sep 23 '22 03:09

Marta Garcia