How to prevent Browser cache for php site

前端 未结 5 1152
野趣味
野趣味 2020-11-22 10:34

I have a php site running in cloud server.When ever i add new files css, js or images the browser is loading the same old js, css and image files stored in cache.

My

5条回答
  •  孤城傲影
    2020-11-22 11:04

    Here, if you want to control it through HTML: do like below Option 1:

    
    
    

    And if you want to control it through PHP: do it like below Option 2:

    header('Expires: Sun, 01 Jan 2014 00:00:00 GMT');
    header('Cache-Control: no-store, no-cache, must-revalidate');
    header('Cache-Control: post-check=0, pre-check=0', FALSE);
    header('Pragma: no-cache');
    

    AND Option 2 IS ALWAYS BETTER in order to avoid proxy based caching issue.

提交回复
热议问题