htaccess - How to force the client's browser to clear the cache?

前端 未结 12 1390
情歌与酒
情歌与酒 2020-12-07 14:23

For my site I have the following htaccess rules:

# BEGIN Gzip

AddOutputFilterByType DEFLATE text/text text/html text/plain tex         


        
12条回答
  •  自闭症患者
    2020-12-07 14:55

    Use the mod rewrite with R=301 - where you use a incremental version number:

    To achieve > css/ver/file.css => css/file.css?v=ver

    RewriteRule ^css/([0-9]+)/file.css$ css/file.css?v=$1 [R=301,L,QSA]

    so example, css/10/file.css => css/file.css?v=10

    Same can be applied to js/ files. Increment ver to force update, 301 forces re-cache

    I have tested this across Chrome, Firefox, Opera etc

    PS: the ?v=ver is just for readability, this does not cause the refresh

提交回复
热议问题