1

I have been using Blitz caching on a Craft (v3.759) site and it is working well. I recently added a second site using Craft's multisite capability. This second site uses a different domain and I have it set up so the public folder for the second site sits alongside the first sites public (web) folder.

When I initialised Blitz settings on the second site, the cache/blitz/sitename folder is written with cached files and when I check the Inspect code on a page via the browser I can see the Blitz comment info added. The blitz.log is also enabled and nothing to report there.

Then when I make a change to an entry (or template file) I can see the refresh notifications in Craft CP happening but the cache files are not updated (for the second site only, everything works fine in the first site). I have tried with a really basic file (one line of template, and no database calls) and same story. The initial cache file is always created but the updates are not written. If I delete the cache file then a new file is created if needed, but also not updated subsequently. Nothing shows in the enabled logs (which are logging other things as expected).

If I use any Blitz buttons to do the job of refreshing - the same result - updates of new files and no update of existing cached files.

The file and folder permissions for the two sites caching folders are identical. The config file settings also look the same for the two sites.

I'm hoping someone has ideas about why the second site's cache files are not updating.

Thanks in advance :).

2 Answers 2

1

Just in case, make sure that your second site is included for the cache pattern

If everything is in order here, check the logs. The cache may not be created due to pending image transformations and if you have enabled the yii2 profiler(debugger tool).

https://putyourlightson.com/plugins/blitz#the-site-is-not-being-cached-when-i-visit-it

5
  • Thanks @RomanAvr . As far as I can tell all that is done properly. The cache pattern has been set for the whole site or individual files and in each case seems to be working as the initial written cache files always match what I add as cache pattern. Logs are not showing anything related to the cache files (but are showing other things like cache exclusions as expected). Debugger tool is turned off, and problem is same in incognito mode. And nothing else is going on like image transforms, and have tried to get this to work for over 24 hours and it has never once worked for subsequent updates Commented Mar 22, 2023 at 22:00
  • Okay, do the easiest trick. Create an empty template and open it on the problem site, will this page be cached?
    – RomanAvr
    Commented Mar 22, 2023 at 22:09
  • An empty template behaves like the others. It is cached initially and I can see the file and when I view it in the browser it has the blitz comments. So far so good. However, when I edit the blank template and add something like "Hello World" then the new version of the web page is not getting written to the cache folders, and the original blank version is the only one available in the browser - it does not update. If I delete the original cached file then the new updated one is written, but itself can then not be overwritten. Commented Mar 23, 2023 at 1:09
  • Sounds really weird. You can ask Ben Croker for the help github.com/putyourlightson/craft-blitz/issues
    – RomanAvr
    Commented Mar 23, 2023 at 7:40
  • 1
    Thanks @RomanAvr for that advice which I took. Without delay Ben was very helpful and we established the combination of factors that caused this situation. I have added a separate answer with the details. Commented Mar 26, 2023 at 19:20
1

After some work and discussion with Ben the creator of the Blitz plugin, it was determined that the issue arose in the following situation:

  • two (or more) unique web document roots were being used e.g. /web and /web2 for each site respectively, and
  • Blitz File Storage (the recommended default) was set, instead of Yii Cache Storage. Yii storage would be better for this situation, and
  • The cache storage Folder Path was left as the default '@webroot/cache/blitz'. This resulted in two separate cache folders (one in each web root). The files in these folders would be created without issue but could be updated inconsistently (mostly not).

If only two of the above three conditions were met then likely there would be no problem. I elected to go with hard-coding the cache storage Folder Path so both sites are cached into only one of the web roots.

A big thanks to Ben, as I think he put a fair bit of time into resolving this for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.