-
☆ A M B ☆
- 450 Posts
I've observed (although not very scientifically) that the behavior of uncached snippets called from cacheable resources has changed from version to version. In the past I have called certain snippets uncached when needed, but have not worried or thought about the 'Cacheable' setting on the calling resource - it is set to cacheable by default, and my code has worked the way I want it to in this scenario. But then when I upgrade MODX, the behavior changes and output that shouldn't be getting cached starts to get cached.
Most recently, I upgraded from 2.2.6 to 2.2.8 last week, and a custom login page stopped working properly. This was a resource that had been left with the default "cacheable" setting, but had two uncached snippets called in it. The snippets began intermittently not firing, and I think it has to do with cache issues. I looked at the resource itself this morning, and set the "cacheable" setting to false, and now the snippets seem to be properly firing every time.
So: is the official rule that if you want uncached snippet output, you have to both call the snippet uncached and set the calling resource to uncacheable? If so, has this always been the rule, or when did it become the rule?
-
☆ A M B ☆
- 24,524 Posts
That should not be happening. A cached resource with uncached snippets should behave as expected: the resource is processed and cached except for the uncached snippet tags, which are processed after the page is loaded from cache. If this is not happening, then something else is going on.
-
☆ A M B ☆
- 24,524 Posts
For example, two otherwise identical cached resources with simple Wayfinder calls, one cached and one uncached, have this difference in their cache files:
'_content' => '<html>
<head>
<title>MODX Revolution - Home</title>
<base href="http://localhost/revo228/" />
</head>
<body>
<ul><li class="first active"><a href="http://localhost/revo228/" title="Home" >Home</a></li>
<li class="last"><a href="index.php?id=2" title="Testing" >Testing</a></li>
</ul>
</body>
</html>',
'_content' => '<html>
<head>
<title>MODX Revolution - Testing</title>
<base href="http://localhost/revo228/" />
</head>
<body>
[[!Wayfinder? &startId=`0`]]
</body>
</html>',
-
☆ A M B ☆
- 450 Posts
I'm going to have to do a little more research on this. What you have said makes total sense and fits with what my understanding had been of how uncached snippets should work. I've found a few other problems related to the situation that triggered this post, so maybe I was cause-jumping. Or solution-jumping. Or something like that.
-
☆ A M B ☆
- 427 Posts
I discussed this in my book. I went as far as to go into the cache, grab the contents of a resource from the cache and showed the difference of what actually happens when the cache is in effect.
I also monitor changes for the classes here:
http://www.shawnwilkerson.com/modx-revolution/2013/04/11/compare-modx-revolution-objects/
Sottwell, is correct. You are not experiencing intended behavior.
Try hard deleting the cache: hit Clear cache in the Manger and delete everything in the /core/cache folder. I would also check the error logs (both in the Manager and in the Server software) and see if any of your snippets are causing an issue.
Are the snippet tags in a chunk, by any chance? That's the only think I can think of that would cause them not to fire. If they're in the template or page content, even if things go wrong, you might see the wrong output or result, but they should still act as if they fired.
The only way to really understand what's happening is to look at the files in the core/cache folder. You can see which tags are still there and which have been replaced.
I wonder if there's a MODX cache unit test around somewhere. If not, there should be.