Wordpress and cache

  • | 224 points

    Hi all,
    loving my Laragon experience, apart from one small thing. My changes do not show in Chrome unless I clear browser cache. I have no cache plugin installed, I never do while sites are in dev, so how do I get over this constant ctrl shift del cycle to clear my caches in Chrome? I did not have this problem with the last locahost app i used.
    Thank you!

  • | 290 points

    This is a common issue with Chrome and other browsers. Browsers usually try to cache as much as they can, so that the user can browse faster. While this is convenient for the average user, it does not help web developers. You can partially prevent this from happening through WordPress, or you can use a browser extension. I personally do a combination (with the WordPress-part being more for the end-users).

    The extension I am using is called "Classic Cache Killer". This extension, when enabled, clears your cache on every page view. It ensures you have the latest version of the HTML, CSS, JavaScript and other assets.

    To leverage this within WordPress, you will need to write/alter some code. With enqueues, you can specify a different version every time the file is updated or have the version set to time(). This changes the URL, and as such browsers will re-fetch the file. This is especially useful for mobile browsers (notably Safari), as their caching is even more persistent than the caching of desktop browsers.

    You could also set some headers in the htaccess-file or document, that disallow caching, but I don't have any experience with this.

  • | 224 points

    Thank you. Check this out now.

  • | 3487 points

    To disable the cache entirely via the .htaccess file, you could use this:

    <filesMatch ".(html|htm|js|css|jpg|png|jpeg|gif)$">
    FileETag None
    <ifModule mod_headers.c>
    Header unset ETag
    Header set Cache-Control "max-age=0, no-cache, no-store, must-revalidate"
    Header set Pragma "no-cache"
    Header set Expires "Wed, 11 Jan 1984 05:00:00 GMT"

  • | 3487 points

    And to expand upon what @RobinHisgen was referring to, here's a simple of example of what I do to cache-bust my JS / CSS files:

    function some_script() {

    wp_enqueue_script('Script Name', get_template_directory() . '/js/some-script.js', array(), date('h:i:s'), true); // Note the "date('h:i:s')".


    add_action('wp_enqueue_scripts', 'some_script');

Log in to reply

Looks like your connection to Laragon was lost, please wait while we try to reconnect.