htaccess - 如何强制客户端的浏览器清除缓存? [英] htaccess - How to force the client's browser to clear the cache?

查看:31
本文介绍了htaccess - 如何强制客户端的浏览器清除缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的网站,我有以下 htaccess 规则:

For my site I have the following htaccess rules:

# BEGIN Gzip
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
</IfModule>
# END Gzip

# BEGIN EXPIRES
<IfModule mod_expires.c>
    ExpiresActive On
    ExpiresDefault "access plus 10 days"
    ExpiresByType text/css "access plus 1 month"
    ExpiresByType text/plain "access plus 1 month"
    ExpiresByType image/gif "access plus 1 month"
    ExpiresByType image/png "access plus 1 month"
    ExpiresByType image/jpeg "access plus 1 month"
    ExpiresByType application/x-javascript "access plus 1 month"
    ExpiresByType application/javascript "access plus 1 month"
    ExpiresByType application/x-icon "access plus 1 year"
</IfModule>
# END EXPIRES

我刚刚更新了我的网站,在我清除缓存之前,它看起来很糟糕.如何在更新后强制客户端的浏览器清除缓存,以便用户可以看到更改?

I've just updated my site and it looked all screwy until I cleared my cache. How can I force the client's browser to clear the cache after an update so that the user can see the changes?

推荐答案

您可以强制浏览器缓存某些内容,但是

You can force browsers to cache something, but

因此,唯一的 (AMAIK) 方法是为您的资源使用新网址.类似于版本控制.

Thus the only (AMAIK) way is to use a new URL for your resources. Something like versioning.

这篇关于htaccess - 如何强制客户端的浏览器清除缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆