Search code examples
phpbrowser-cachecache-control

How to prevent browser caching of assets called from PHP pages?


Whenever I update CSS, JS, or image files the browser is loading the same old files stored in cache. How can I prevent this? I am serving my site pages with PHP.


Solution

  • try this

    <?php
    
    header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");
    ?>