Any reason not to add “Cache-Control: no-transform

2020-05-25 08:11发布

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?

2条回答
欢心
2楼-- · 2020-05-25 08:29

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

查看更多
Anthone
3楼-- · 2020-05-25 08:29

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

查看更多
登录 后发表回答