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: Escape in static caching? Tags created when not cached?
Status | Resolved |
Add-on / Version | Speedy 1.3.1 |
Severity | |
EE Version | 5.4.2 |
Hop Studios
May 12, 2021Hello there,
Is it possible to actually have the escape logic in static caching?
Also a separate question, I set up these ignore settings
$config['speedy_driver'] = 'static';
$config['speedy_static_enabled'] = 'yes';
$config['speedy_static_settings'] = [
'ignore_urls' => [
['url' => '^[a-z]{2}/store'],
['url' => '^[a-z]{2}/search'],
['url' => '^[a-z]{2}/donate'],
['url' => '^[a-z]{2}/store/.*'],
['url' => '^[a-z]{2}/search/.*'],
['url' => '^[a-z]{2}/donate/.*'],
['url' => '^store'],
['url' => '^search'],
['url' => '^donate'],
['url' => '^store/.*'],
['url' => '^search/.*'],
['url' => '^donate/.*']
],
];
When I visit those pages they don’t get cached but a row will be inserted into exp_speedy_tags table. Here’s my template code:
{exp:speedy:static tags="{if layout:speedy_tags}{layout:speedy_tags}{/if}" url_prefix="{if publisher:current_language_id != publisher:default_language_id}{publisher:current_language_code}{/if}"}
Don’t know if this is intended for other reasons.
- Gil
BoldMinded (Brian)
May 12, 2021
I’ll take a look at the tag thing, that is odd.
To answer your first question, no there isn’t a way to use the escape tag in static caching since it is designed to bypass EE entirely. What you’re referring to is “hole punching”. If you need to have part of a static page not cached, your best bet is to make an Ajax request to a partial that contains the non-cached data, like a user profile or shopping cart thing in the header of a page.
Hop Studios
May 12, 2021
Let’s say if I want to use PHP to read cookie `exp_session` to determine if the user is logged in. Is there a file (maybe in utilities) that I can add this logic to? Maybe I’ll append a $_GET to show the non-cached version (which is possible right like ?nocache=1).
- Gil
BoldMinded (Brian)
May 14, 2021
There isn’t anything like that, sorry. Sounds like custom work. You’d have to add something to the index php file that Speedy generates.
Hop Studios
May 14, 2021
Can you point me in the right direction where the index PHP file is generated?
- Gil
Hop Studios
May 18, 2021
Hello Brian,
In case you missed my previous message, can you please give me some hints on what files I might want to look at to modify the index.php generation process? Thanks!
- Gil
BoldMinded (Brian)
May 18, 2021
There really is no great place to intercept b/c if you’re using static caching, each cached page is it’s own php file. They all load the static/utilities/StaticCacheHelper.php file though, but if you modify that Speedy might try to regenerate it if you change any cache settings. You might be better off changing your htaccess file to load a custom index.php file, that then loads the cache file, e.g. what is in your htaccess file: /static/default_site/static%{REQUEST_URI}/index\.php [L,QSA]
Hop Studios
May 21, 2021
Hello Brian,
I’d like to share my approach to enable a login check. In StaticDriver.php around line 82 I added:
and in my .htaccess file I added no_cache to the condition
This obviously doesn’t check if the user’s logged in roles/groups but we don’t need that for this site.
- Gil