htaccess - 如何强制客户端的浏览器清除缓存?

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.