We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 20093
    • 81 Posts
    I am having an issue with MODx where the cache files within core/cache/resource/resources (and probably others) are being deleted as soon as they are created, leading to extremely slow page load times. This is happening on pages set as Cacheable. All my _expires settings related to cache are set to 0.

    Any idea why this is happening? [ed. note: MokoJumbie last edited this post 12 years, 1 month ago.]
      • 3749
      • 24,544 Posts
      Are you saving resources or elements in the Manager? That clears the cache.


      ---------------------------------------------------------------------------------------------------------------
      PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
      MODX info for everyone: http://bobsguides.com/modx.html
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 20093
        • 81 Posts
        I'm not making any changes in the manager while this is occurring. I'm just requesting a page in the front end. As the page loads, I can see the cache file created, but then, immediately after the request is completed, the cache file is no longer there.

        This is on a remote FTP server. I've also tried running some tests on a fresh local install and i can see the cache file is created for requested pages. Subsequent frequent page requests are usually quick to load, 42ms vs. several seconds, but for page requests having longer intervals the server seems to rebuild the page from scratch regardless of the presence of the cache file. I'm not sure if there is any correlation between the two behaviours, but I sure would like to understand why they are happening.
        • Definitely should not be happening unless you have code doing so in a plugin or snippet executing on the front-end.
            • 20093
            • 81 Posts
            Thanks. After some testing i found the culprit. It's digitalbutter's Mirror, which synchronizes the copies of your Chunks, Snippets, Plugins and Templates in the db with versions on the filesystem.

            I filed an issue on the github tracker and recieved a prompt response:

            @MokoJumbie for now that is deliberate.

            We don't use this on production, it's for development only. If you do want to use it on production, then the recommended strategy for now is to change the plugin event to onSiteRefresh (when cache is already flushing) so that Mirror can remove all cached elements and your code change can be reflected. This way, you'll invoke mirror at only key points (e.g. when the cache should be cleared anyway).

            Another thing we have been doing recently (also for development only) is to stop execution of the plugin if &flush=1 is not found in the URL parameters.

            Any other suggestions based on your use case or insight would be appreciated!

            Maybe this information will be useful for someone else.