I'm witnessing a super odd behavior in Revo 2.2.0-pl2:
I use a snippet to inject some html before </body> with $modx->regClientHTMLBlock(); It worked great for months. Right now the html is injected *only* on the very first page load after clearing the site cache. On subsequent page loads no html is injected o_O The snippet wasn't edited since it last worked.
Some help would be more than welcome.
[ed. note: yogooo last edited this post 14 years, 8 months ago.]
What happens if you call the snippet uncached?
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html
As I understand it, the snippet cache can only cache the *return value* of the snippet, and when the snippet is cached, that return value is pulled from the cache and the snippet doesn't actually execute, the regClient*() call isn't made, and the HTML or the page doesn't get modified.
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html
-
☆ A M B ☆
- 24,524 Posts
So the first time the page is generated, the snippet runs and the HTML is inserted. The page is cached with the HTML. On subsequent loads from cache it should still be there, no?
Something else must be at play here; it's working fine for me.
[ed. note: sottwell last edited this post 14 years, 8 months ago.]
The page itself would have to be marked cacheable.
-
☆ A M B ☆
- 24,524 Posts
Do you mean that a snippet's output can be cached, while the page itself is not?
I think any element in Revolution can be cached or uncached independent of everything else -- even placeholders and language tags.
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html
Thanks for the explanation Bob. And yep, the resource is marked as cacheable.
While calling the snippet uncached works wonders, and as sottwell says, there must be something else at play. I used to call it cached on three different templates and it worked flawlessly. This morning it stopped working on the two other templates, so now I call it uncached everywhere... it works but it's weird that it stopped working all of a sudden (config didn't change, snippet didn't change either).
I looked for some documentation on regClient*() execution and caching, nothing found. Is there a way to trace the modx parser step by step to see what's happening?
It's hard to trace things unless you run the whole site under a debugger, and that can be pretty tedious and hard to set up. You can look in the core/cache directory, though, and see what's being cached.
---------------------------------------------------------------------------------------------------------------
PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
MODX info for everyone:
http://bobsguides.com/modx.html