All add-ons currently require PHP 7.4 or greater.
On July 4th 2024 PHP 8.2 will be the new minimum requirement for all add-ons. Expect any add-on released after that date to require 8.2 or greater. Some releases may not immediately take advantage of 8.x specific features in PHP, which means you might, be able to continue using new releases in PHP 7.4, however, if you experience an error the first thing you should do is update to PHP 8.2 then create a support ticket if the error persists.
Publisher does not support the Fluid field type. Please do not contact asking when support will be available.
If you purchased an add-on from expressionengine.com, be sure to visit boldminded.com/claim to add the license to your account here on boldminded.com.
Ticket: speedy escaping doesn’t work where I think it should.
Status | With Customer |
Add-on / Version | Speedy 1.9.2 |
Severity | |
EE Version | 7.2.6 |
Paul Larson
May 03, 2024Below is a template skeleton. Pretty simple sandwich of:
- exp speedy fragment
- exp channel entries
- a few speedy:escapes
- closing channel entries
- closing fragment.
Yet, it doesn’t seem to be escaping. “I am in escape A” is present in the system/user/cache/speedy filesystem and I would expect that it shouldn’t be there.
File driver is default/file.
{layout='includes/_layout_2021'}
{exp:speedy:fragment ttl="43200" global="no" key="{segment_2}-entry-contents"}
{exp:channel:entries disable='member_data|pagination' limit="1" require_entry='yes' status='open|collection'}
{exp:speedy:escape} {!-- ******* escape A --}
<!-- ****** I am in escape A -->
{layout:set name='seo'}
<!-- lots of meta info -->
{/layout:set}
{/exp:speedy:escape} {!-- ******* end escape A --}
{exp:speedy:escape} {!-- ******* escape B --}
<!-- ******* I am in escape B -->
{matrix_field}
{embed="some/embed"}
{/matrix_field}
{/exp:speedy:escape} {!-- ******* end escape B --}
{/exp:channel:entries}
{/exp:speedy:fragment}
Paul Larson
Comment has been marked private.
Paul Larson
The TLDR is:
If File is cache method.
And I put {exp:speedy:escape} Hi I’m Fred Flintstone {/exp:speedy:escape}…
…I would think that text would not be in system/user/cache/speedy….
Paul Larson
Hopefully an even simpler reduction template.
This has two escapes, #1 and #2. The content of both escapes appears in the stored cache file. That shouldn’t be the case, right? (for data I specifically don’t want cached?)
BoldMinded (Brian)
Escaping means it should be saved in cache, it just remains unparsed. So when the cache item is printed back out to the page, if there are EE tags in there, they will get parsed live.
BoldMinded (Brian)
For example, if you want to cache an item but show unique content to the logged in user, you might use an escape tag like this:
FWIW this is using the pre-escape method so early parsed global variables still work, but the same concept applies.
Paul Larson
Let me ponder.
Ultimately I have an {embed} (a rather complicated one) that delivers a simple badge In Stock if a product is in stock.
But that embed seems to never parse, so it’s always showing an obsolete value. (That is: In Stock when the item is actually at zero inventory, or empty when it is in fact in stock)
With your advice I’m going to revisit that template (and the contents of the cache) to see if I can unravel it.
Paul Larson
Brian,
In this example, shouldn’t my {current_time} tag remain unparsed, then? (instead of baking in the time from the last time the cache was saved?)
screenshot:
https://app.screencast.com/ifOJeChfxbA1i
Or below:
<iframe scrolling=’no’ frameborder=’0’ 2470px; height: 1944px; border:0;’ src=’https://app.screencast.com/ifOJeChfxbA1i/e’ allowfullscreen></iframe>
Paul Larson
Maybe screenshots are overkill.
Template code:
Cache result:
BoldMinded (Brian)
current_time is already parsed when escape is getting called, so it will cache the result of the current_time variable. However, if you use a modifier the escape tag will parse earlier and it will escape the current_time var.
template:
Cached item:
BoldMinded (Brian)
The escape tag is working, I think you’re just running into parse order issues.
Paul Larson
I understand parse order can be an issue.
But I don’t see that come to bear in this template. For this reduction template, the code I’m showing is literally the extent of the template. No partials, no embeds, no if_logged in.
I added a custom field {LONG_DESC} (just to avoid {title} and {current_time} getting special treatment), and even that is cached instead of remaining un-parsed.
Should not ” Let’s try a custom field of {LONG_DESCR}” be stored un-parsed in cache?
I don’t see the normal parse order speed bump in this very basic template.
BoldMinded (Brian)
The custom field should still getting parsed. If you escape it, then the cached version has no entries tag around it to parse it on output.
If you use the pre-escape option (exp:speedy:escape:modifier_here} then it won’t parse the custom field values.
The parsing of the fragment and escape tags have been unchanged basically since Speedy’s inception. I don’t know what else to say other than parse order is going to be a factor, and if the escape tag without the pre-escape modifier doesn’t work as expected, then to try the pre-escape modifiers.
BoldMinded (Brian)
Results in
Paul Larson
Ultimately, I have an “In Stock” icon that needs to display appropriately. It’s the output of an {embed}.
a) I’m just not sure, then, how to ensure the “In Stock” icon is always using live, instead of cached, data.
I thought :escape was the way to do this. Can I only escape outside of channel entries loops?
b) Just so I’m clear. Take my test template out of the picture. Generally speaking, if this code below is within exp:speedy:escape tags, what would you expect to be the default output? I can work backwards from there.
BoldMinded (Brian)
I have some thoughts and I’ll try to elaborate on this more tomorrow when I’m at a computer. Thanks for the context, it helps to understand the situation.
As for that example I would expect it to cache and render exactly what you have there bc that variable is unparsed.
Paul Larson
Thanks! I might make a simple (yet realistic) template with the embed just to provide more context.
BoldMinded (Brian)
If you’re going to go with the embed route, then you might want to pass the entry ID so it is cached as
I tested this and it does parse the
entry_id
variable, but not the embed.Another option is load the dynamic values with Ajax after the cached page is initially loaded, like demonstrated in the docs https://docs.boldminded.com/speedy/docs/static-caching/real-world-example. If you had a grid of 9 products you could figure out which entries are being displayed on the page, perhaps add all the entry ids onto a data attribute somewhere, then perform a single Ajax request to fetch the status of those entries, then update the DOM based on the Ajax response to indicate if a product is available or not. This would let you cache an entire section of the page, but then make real time updates of certain attributes of the products. This is mostly useful when using full page caching, but could be used with partial fragment caching too.
If you’re going to use an embed to get the status of each product, I’m not sure how much faster that will be since you’ll still have X embeds and X entries tags to get that info, which is why a single Ajax call to a template (or php based ACT endpoint) would be faster. Make the response a JSON object and javascript to perform the DOM updates.
Paul Larson
Ok, here is the same template situation but much closer to what is actually employed on the site. Two exp:channel:loops, one with speedy escape, one without speedy of any kind.
As is, my {embed} already references the entry_id, so I believe it uses your last suggestion. “If you’re going to go with the embed route, then you might want to pass the entry ID…”
I still think what I have should work, with how I understand Speedy. I could absolutely be mistaken, though.
Here is the full embed, if it helps. It’s ugly, so I tried to spare you as long as possible.
I’ll follow up with a brief private video.
Paul Larson
Comment has been marked private.
BoldMinded (Brian)
That looks more like a cache clearing rules issue than an issue with fragments and escaping.