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: Proper syntax for Cache Clearing settings per channel

Status Resolved
Add-on / Version Speedy 1.3.2
Severity
EE Version 6.0.6

Paul Larson

Sep 21, 2021

Screenshot:

https://www.dropbox.com/s/81jzc02ucvzo7xd/2021-09-21_12-54-10.png?dl=0

Given that stored Speedy cache of local/barstool/*

Would the Channel Settings, below, be correct to: clear local/barstool/ cached items when a Barstool entry is saved?

https://www.dropbox.com/s/3y1zhu3odjakbfi/2021-09-21_12-55-19.png?dl=0

Saving a trivial edit to Barstool channel does not seem to trigger a cache clearing as I’d expect.

#1

Paul Larson

I should add that File is the cache driver. Nothing too adventerous.

#2

BoldMinded (Brian)

What are the rest of your Speedy settings? Particularly speedy_enable_refresh, and speedy_break_async? If speedy_break_async is set to yes, try setting it to no.

#3

Paul Larson

Do you mean in config.php?

I actually have no speedy settings in config.php at the moment. (wasn’t sure they were needed unless it was specific for redis, etc)

#4

BoldMinded (Brian)

Take a look at the docs and try those values I mentioned.

#5

Paul Larson

Comment has been marked private.

#6

BoldMinded (Brian)

Did you try setting the async option to no?

#7

Paul Larson

That may have “worked,” in that the cache was refreshed, but then EE threw a Redis error (which is not enabled)

RedisException Caught Redis server went away user/addons/speedy/Service/Drivers/RedisDriver.php:244

Stack Trace: Please include when reporting this error

0 user/addons/speedy/Service/Drivers/RedisDriver.php(244): Redis->scan()

1 user/addons/speedy/Service/Drivers/RedisDriver.php(216): BoldMinded\Cache\Service\Drivers\RedisDriver->getIterator()

2 user/addons/speedy/Service/CacheBreaker.php(432): BoldMinded\Cache\Service\Drivers\RedisDriver->getItemsFromPath()

3 user/addons/speedy/Service/CacheBreaker.php(208): BoldMinded\Cache\Service\CacheBreaker->collectItemsFromPath()

4 user/addons/speedy/Service/CacheBreaker.php(82): BoldMinded\Cache\Service\CacheBreaker->_breakEntryCache()

5 user/addons/speedy/ext.speedy.php(105): BoldMinded\Cache\Service\CacheBreaker->breakEntryCache()

6 ee/legacy/libraries/Extensions.php(203): Speedy_ext->after_channel_entry_save()

7 ee/legacy/libraries/Extensions.php(108): EE_Extensions->call_class()

8 [internal function]: EE_Extensions->call()

9 ee/ExpressionEngine/Service/Model/Model.php(642): call_user_func_array()

10 [internal function]: ExpressionEngine\Service\Model\Model->ExpressionEngine\Service\Model\{closure}()

11 ee/ExpressionEngine/Service/Model/Model.php(588): call_user_func_array()

12 [internal function]: ExpressionEngine\Service\Model\Model->ExpressionEngine\Service\Model\{closure}()

13 ee/ExpressionEngine/Service/Event/Emitter.php(132): call_user_func_array()

14 [internal function]: ExpressionEngine\Service\Event\Emitter->emit()

15 ee/ExpressionEngine/Library/Data/Entity.php(614): call_user_func_array()

16 [internal function]: ExpressionEngine\Library\Data\Entity->emit()

17 ee/ExpressionEngine/Service/Model/Model.php(821): call_user_func_array()

18 ee/ExpressionEngine/Service/Model/Query/Update.php(49): ExpressionEngine\Service\Model\Model->emit()

19 ee/ExpressionEngine/Service/Model/DataStore.php(275): ExpressionEngine\Service\Model\Query\Update->run()

20 ee/ExpressionEngine/Service/Model/DataStore.php(240): ExpressionEngine\Service\Model\DataStore->runQuery()

21 ee/ExpressionEngine/Service/Model/Query/Builder.php(71): ExpressionEngine\Service\Model\DataStore->updateQuery()

22 ee/ExpressionEngine/Service/Model/Model.php(353): ExpressionEngine\Service\Model\Query\Builder->update()

23 ee/ExpressionEngine/Model/Content/ContentModel.php(219): ExpressionEngine\Service\Model\Model->save()

24 ee/ExpressionEngine/Controller/Publish/AbstractPublish.php(377): ExpressionEngine\Model\Content\ContentModel->save()

25 ee/ExpressionEngine/Controller/Publish/Edit.php(501): ExpressionEngine\Controller\Publish\AbstractPublish->saveEntryAndRedirect()

26 [internal function]: ExpressionEngine\Controller\Publish\Edit->entry()

27 ee/ExpressionEngine/Core/Core.php(251): call_user_func_array()

28 ee/ExpressionEngine/Core/Core.php(111): ExpressionEngine\Core\Core->runController()

29 ee/ExpressionEngine/Boot/boot.php(161): ExpressionEngine\Core\Core->run()

30 admin.php(144): require_once(‘…’)

30 admin.php(144): require_once(‘…’)

#8

BoldMinded (Brian)

Comment has been marked private.

#9

Paul Larson

That seemed to work. I can now save an entry w/o a Redis error. I do get a similar error in the Speedy Dashboard when I click ‘Refresh.’

GIF: https://www.dropbox.com/s/hqnp6rx0d1xomkf/2021-10-07_10-02-08%20%281%29.gif?dl=0

Text:

RedisException Caught Redis server went away user/addons/speedy/Service/Drivers/RedisDriver.php:244

Stack Trace: Please include when reporting this error

0 user/addons/speedy/Service/Drivers/RedisDriver.php(244): Redis->scan()

1 user/addons/speedy/Service/Drivers/RedisDriver.php(216): BoldMinded\Cache\Service\Drivers\RedisDriver->getIterator()

2 user/addons/speedy/Service/Drivers/RedisDriver.php(330): BoldMinded\Cache\Service\Drivers\RedisDriver->getItemsFromPath()

3 user/addons/speedy/mcp.speedy.php(251): BoldMinded\Cache\Service\Drivers\RedisDriver->refresh()

4 [internal function]: Speedy_mcp->refresh_data()

5 ee/ExpressionEngine/Controller/Addons/Addons.php(1397): call_user_func_array()

6 ee/ExpressionEngine/Controller/Addons/Addons.php(701): ExpressionEngine\Controller\Addons\Addons->getModuleSettings()

7 [internal function]: ExpressionEngine\Controller\Addons\Addons->settings()

8 ee/ExpressionEngine/Core/Core.php(251): call_user_func_array()

9 ee/ExpressionEngine/Core/Core.php(111): ExpressionEngine\Core\Core->runController()

10 ee/ExpressionEngine/Boot/boot.php(161): ExpressionEngine\Core\Core->run()

11 admin.php(144): require_once(‘…’)

11 admin.php(144): require_once(‘…’)

#10

Paul Larson

Comment has been marked private.

#11

Paul Larson

My video sort of surprised me at the end (as one cache clear seemed to work). But, the TL;DR is that basic testing of cache clearing triggered by a channel entry save is hard to implement. I might be missing something super obvious. Others on slack seem to have same issue.

#12

BoldMinded (Brian)

In the video you saved the entry then immediately refreshed it on the front-end. Before reloading it on the front-end, and thus giving it a chance to re-generate the cache items, what is in the cache immediately after the entry save?

FWIW the unit tests covering the cache clearing are pretty thorough, so when issues like this are reported I’m less hesitant to jump into the code to see why it might not be clearing. It usually ends up being an issue with the template tags or the cache busting rules being improperly defined, but from what I can tell they rules look correct.

#13

Paul Larson

Comment has been marked private.

#14

BoldMinded (Brian)

Paul, I’m incredibly busy this week and next week, and this seems like an issue that would take some time to dig into. For now, you might have to do some of your own debugging. In the CacheBreaker.php file is a method _breakEntryCache(). Add some logging there (not var_dump(), die, or exits, the code needs to execute in full), and see where it might not be clearing the items you’re expecting it to clear, then maybe that’ll reveal the issue.

#15

Paul Larson

Comment has been marked private.

#16

BoldMinded (Brian)

I haven’t heard anything from Aasun about this. If he’s having similar issues ask him to contribute to this thread so I have more information about a potential issue.

#17

Aasun Eble

I’m having the same issue.

I have numerous global speedy fragments that are used throughout my templates. I have those different fragments set to clear items with the path to the cache item.

The clearing doesn’t happen when the channel gets updated. I can manually clear the caches fine.

I also hav ether “Refresh Items” switch turned on, so that when the caches clear, the cache auto-refreshes. This also doesn’t work. The cache will get regenerated the first time a template loads that contains the speedy cache fragment.

To reiterate…The caching works and the tags work and it really improves the performance dramatically. I’m using global cache fragments (somethign that native EE caching can’t do). It’s just that the automatic clearing/refreshing is not working.

#18

BoldMinded (Brian)

Aasun, can you please provide screenshots or videos of your settings page, template code, Speedy config settings in your config.php file etc. I need more information before I can try to replicate the issue locally.

#19

Paul Larson

{exp:speedy:fragment driver=”file” key=”barstool_images_fourth”} {barstool_images limit=’1’ } [… code that displays images] {/barstool_images} {/exp:speedy:fragment}

#20

Aasun Eble

I’ve got various global speedy fragments used on multiple templates..

{exp:speedy:fragment global="yes" key="pp_non_greeting_prints" ttl="0"}
   {exp:channel:entries channel="assets_prints_backgrounds" entry_id="9488" dynamic="no" disable="categories|member_data|pagination"}
  [...code displaying content and images...]
     {/exp:channel:entries}
 {/exp:speedy:fragment}

Then, under “Cache Clearing Rules” for the channel that has my Background Print Assets (short name: assets_prints_backgrounds), under the “clear items” tab, I have this entered: global/pp_non_greeting_prints (I also have other global cache fragments that use the same channel, clearing. So, I have 6 rows in here, in total).

Then under the “Refresh Items” tab, I have “Refresh Items” toggle turned on.

I don’t have any settings in the “Clear Tags” tab.

#21

Paul Larson

Comment has been marked private.

#22

Paul Larson

The latest. I simplified they key.

{exp:speedy:fragment driver="file" global="yes" tag="barstool_images_second" key="barstool_images_second-{url_title}"}
                           {barstool_images limit='3'}
                              stuff
                           {/barstool_images}
                        {/exp:speedy:fragment}

View items:

https://www.dropbox.com/s/ayh3ympzens2hny/2021-10-12_11-18-10.jpg?dl=0

Clearing settings for ‘Barstool’ channel:

https://www.dropbox.com/s/x2d6m6v9yicfkwx/2021-10-12_11-19-15.jpg?dl=0

No change on entry change, though. Gotta be something super obvious I’m missing.

#23

Paul Larson

Don’t think I’m fully resolved, but will refine with a new ticket.

Login to reply