We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2231
    • 10 Posts
    Hi, I saw that MODx has a ’cacheable default’ option. Is that caching, if not then what does it do?

    Thanks
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      That sets a document’s cacheable checkbox to checked automatically (or not). There are similar settings for other default document settings such as searchable or published.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 2231
        • 10 Posts
        So is is this a yes? I’m looking at MODx for a possible website, seeing as the thing I want to try will query the DB quite a lot, I’d like the front-page to be cached and get a refresh every 30 minutes or so. Is this possible?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          No, once a document is cached that is only cleared when the cache is cleared on saving an edited document or manually clearing the cache.

          The parser checks for the existance of a cache file for the document it’s parsing and uses that instead of generating a new page if the cache file exists. Clearing the cache simply deletes the page cache files, and the next time a page which is set to be cached is requested a new cache file is written to the cache folder for it.

          Of course, you could write a snippet to do something along those lines, but it’s not part of the core caching system.

          A plugin could write the time to a file whenever a cache file is created for that page, then every time the page is accessed use another event to check the file and if the current time is greater than 30 minutes more than the time in the file, delete the document’s cache file. You might be able to just use the create time of the cache file instead of writing the time to a separate file.

          If you literally want the cache file deleted every 30 minutes, that would be a "cron" job. Some hosting control panels have a cron list that you can add to, but I think you’d need to have a perl or php script able to run from the command line to add.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 2231
            • 10 Posts
            Hello again,

            I haven’t stated that I plan on using the PieX snippet to do the base work for this. PieX is a feed aggregator based on SimplePie which also happens to have it’s own timed cache function. Seeing as the main page would be mainly feeds, would the CMS’ cache update accordingly to the aggregator’s cache or do I need to do some additional hacking for the two to integrate?

            Sorry if this sounds ambiguous, I’m still learning smiley