简体   繁体   English

GZip网站压缩查询

[英]GZip Website Compression Query

I have a small question. 我有一个小问题。

I run an e-commerce site which updates daily. 我经营一个电子商务网站,每天更新。 Following advice, I added the following lines to my .htaccess file in order to improve my site's speed. 遵循建议,我在.htaccess文件中添加了以下几行,以提高网站的速度。

compress text, html, javascript, css, xml: 压缩文字,html,javascript,css,xml:

AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

Now, my problem is that when I load up my website it loads a cached version. 现在,我的问题是,当我加载网站时,它会加载一个缓存的版本。 Being an e-commerce site, I need to display the latest stock information at any given time etc. 作为电子商务网站,我需要在任何给定时间显示最新的股票信息等。

I'm unfamiliar with this whole topic and the above code was originally copied from another source, hence, can someone advise me what to remove/replace with in order to maintain the best site speed and also avoid caching on my product pages etc. 我不熟悉整个主题,上面的代码最初是从其他来源复制的,因此,有人可以建议我删除/替换哪些内容,以保持最佳的网站速度,并避免在我的产品页面上缓存等。

Cheers! 干杯!

These lines only turn on mod_defalate, which compresses your content, it has nothing to do with caching. 这些行仅打开mod_defalate,它将压缩您的内容,而与缓存无关。

You are probably getting a cached version because of varnish or some other cache proxy that is set up between you and the site. 由于您和站点之间设置了清漆或其他缓存代理,您可能会得到缓存的版本。

If you want to make sure that the page is not cached, you should add no-cache headers to your html. 如果要确保未缓存页面,则应在HTML中添加不缓存标题。 For example, something like: 例如,类似:

<FilesMatch "\.(html|htm)$">
  Header unset Etag
  Header set Cache-Control "max-age=0, no-cache"
</FilesMatch>

This tells browsers and proxies not to cache the .html and .htm pages on your site. 这告诉浏览器和代理不要在您的站点上缓存.html和.htm页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM