I’m looking for some help. I’m working on a website where users can create and edit their own documents. After they create the document, I am providing a link so users can access all the documents that they have created. The problem is that the document that the user just created isn’t showing up until I clear the Modx cache. Here’s my setup:
I have a page called "My Units" that uses Ditto to display all the documents that were created by the user who is currently logged in. Under Page settings, I have Cacheable unchecked so the page should not get cached. The Ditto call is also using the uncached syntax [!Ditto... !]. Here’s the Ditto call I’m making on the page.
[!Ditto? &sortBy=`pagetitle` &sortDir=`ASC` &dateSource=`editedon` &dateFormat=`%B %d, %Y` &parents=`19,113` &total=`all` &depth=`100` &display=`10` &filter=`createdby,[*currentUserID*],1` &paginate=`1` &paginateAlwaysShowLinks=`1` &tpl=`ProjectTagChunk` &extenders=`summary,request` &tagData=`ProjectTags` &tagDelimiter=`, ` !]
After I clear Modx cache, the list of documents is contains all the expected documents in the list, so it definitely appears to be a caching problem. Any help would be greatly appreciated.
By the way, this is my first site using Modx and I have been blown away at how incredibly well Modx has been architected. It’s a brilliant system.
-
MODX Staff
- 10,725 Posts
Whenever you publish new content, you must refresh the cache in order for that page to become available, and that will not be available until the next request, even if you do. I generally clear the cache in the script after writing the content to the db and then redirect users to another page that I know will always be published (a landing page if you will) and can then contain a link to the new page.
Thanks OpenGeek, I’ll give that a try and report back after testing it out.
Worked like a charm. I added the following code to clear cache in the snippet after the document is created and now the document appears immediately.
include_once $modx->config[’base_path’]."manager/processors/cache_sync.class.processor.php";
$sync = new synccache();
$sync->setCachepath("assets/cache/");
$sync->setReport(false);
$sync->emptyCache();
Thanks again,
estring