How to force a browser to refresh a cached version of a webpage

前端 未结 9 542
粉色の甜心
粉色の甜心 2020-12-08 10:06

I have a website that because of an ill-prepared apache conf file has instructed users to cache a website URL several years into the future. As a result, when a person visit

9条回答
  •  时光说笑
    2020-12-08 10:58

    You can make all the necessary changes inside the HTML files, like

    
    
    
    
    
    

    But also, you can explicitely tell Apache to use mod_expires.c module, and add a couple of directives to httpd.conf file:

    
      # Turn on the module.
      ExpiresActive on
      # Set the default expiry times.
      ExpiresByType text/html "modification plus 5 seconds"
      ExpiresByType text/javascript "modification plus 5 seconds"
      ExpiresDefault "access plus 2 days"
    
    

    This way you add the http headers cache-control and expires, to responses, in order for thw browser to update the cache 5 seconds after the file was modified in the origin, for those kinds of files, and 2 days after being accessed by the browser for all the other kinds of files.

    Hope this helps.

提交回复
热议问题