Hi, I saw that MODx has a ’cacheable default’ option. Is that caching, if not then what does it do?
Thanks
-
☆ 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.
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?
-
☆ 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.