How to enable gzip compression and leverage browser caching in Pinterest, Twitter and facebook Javascript files.

走远了吗. 提交于 2019-12-13 17:25:04

问题


As part of performance tuning, GTMetrix is suggesting to enable enable Enable gzip compression and leverage browser caching with Pinterest, Twitter and facebook JS files. These are usually done from the server they are served from. I am not able to find out how to request these companies to make these files Gziped and have them cached. Please help in making these files Gziped and cached.

Advance thanks in helping out.


回答1:


Unfortunately you cannot gzip external sources. Unless you have code on your website that actually points to those js/css files, you can't do anything with them. If they point to those files, you could do the following instead:

  1. Copy them over to your server and change your code, so they point to your server.
  2. Create a cronjob on your server that checks for any changes in those external files. If there are differences, copy them over to your server.



回答2:


What do you mean with "how to request these companies to make these files Gziped and have them cached."?

While it's better to serve them GZipped you shouldn't take it as a rule. I'm sure there is a greater reason to them serve it as it is than your achievement of higher rate on GTMetrix. Perhaps, they prefer use a more bandwidth of their high quality servers to minimize users use of CPU by decompressing their files. Perhaps your resources are images and GTMetrix is not dealing proper with it to make an useful suggestion (GZip images is redundant and a backfire).

Despite the obvious fact that you have no control on header properties of external files, an attempt to workaround that could cause cache problems, leading to greater problem than just a performance issue. And I'm sure these external resources by big companies are hit in a very low latency.



来源:https://stackoverflow.com/questions/52804551/how-to-enable-gzip-compression-and-leverage-browser-caching-in-pinterest-twitte

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!