The MODx Cache

The MODx cache (pronounced "cash") is just a temporary storage area that MODx uses to store frequently used information. When MODx renders a document, it has often has to perform a number of tasks behind the scenes before the document is sent to the browser. When a document is marked as "Cacheable," MODx stores the result in the cache so that the next time the document is requested, it can serve up the cached version without performing all the background operations.

It's important to be aware of the cache because, if you change a document in the MODx Manager, the changes won't show up in the "front end" until the cache is cleared. You can prevent this by making sure the Empty cache? checkbox is checked on the document's Page settings tab. When the checkbox is checked, MODx will clear the cache every time that document is saved after being edited.

You should designate a document as cached when the content of the document won't change unless you edit it yourself. That way, the page will take less time to load.

If a snippet on the page produces information that changes every time the page is visited, MODx gives you the option of letting you call the snippet as uncached in a cached page. That way, MODx can cache the rest of the page and fill in the results produced by the snippet every time the page is called.

It is a quirk of MODx (to be remedied in future releases) that when you have a document designated as uncached (the cacheable? checkbox is unchecked) and you put an uncached snippet call on that page, the snippet is actually called cached so the results the user sees may be out of date. The same thing happens with snippets that call other snippets. If the snippet is uncached and calls a second snippet, also uncached, a cached version of the second snippet will be served up. Just remember that when moving from container to contained item, the effect of the cached designation reverses. Generally, you can avoid this by having the page designated as cacheable and call any snippets on the page cached. Snippets called by those snippets should generally be uncached.
 

Thank you for visiting BobsGuides.com

  —  Bob Ray