Answers.Body: <p>After some work and discussion with Ben the creator of the Blitz plugin, it was determined that the issue arose in the following situation:</p>
  <ul>
  <li>two (or more) unique web document roots were being used e.g. /web and /web2 for each site respectively, and</li>
  <li>Blitz File Storage (the recommended default) was set, instead of Yii Cache Storage. Yii storage would be better for this situation, and</li>
  <li>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).</li>
  </ul>
  <p>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.</p>
  <p>A big thanks to Ben, as I think he put a fair bit of time into resolving this for me.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-26T19:18:13.787Z
Answers.LastActivityDate: 2023-03-26T19:18:13.787Z
Answers.UserDisplayName: Jack McKenzie
Answers.Body: <p>Just in case, make sure that your second site <a href="https://i.sstatic.net/Wsn5O.png" rel="nofollow noreferrer">is included for the cache pattern</a></p>
  <p>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).</p>
  <p><a href="https://putyourlightson.com/plugins/blitz#the-site-is-not-being-cached-when-i-visit-it" rel="nofollow noreferrer">https://putyourlightson.com/plugins/blitz#the-site-is-not-being-cached-when-i-visit-it</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-22T22:00:00.320Z
Answers.Text: 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
Answers.UserDisplayName: Jack McKenzie
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-22T22:09:55.867Z
Answers.Text: Okay, do the easiest trick. Create an empty template and open it on the problem site, will this page be cached?
Answers.UserDisplayName: RomanAvr
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-23T01:09:43.393Z
Answers.Text: 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.
Answers.UserDisplayName: Jack McKenzie
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-23T07:40:00.257Z
Answers.Text: Sounds really weird. You can ask Ben Croker for the help https://github.com/putyourlightson/craft-blitz/issues
Answers.UserDisplayName: RomanAvr
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-26T19:20:25.103Z
Answers.Text: 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.
Answers.UserDisplayName: Jack McKenzie
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-22T07:50:11.673Z
Answers.LastActivityDate: 2023-03-22T07:50:11.673Z
Answers.UserDisplayName: RomanAvr
Body: <p>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.</p>
  <p>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.</p>
  <p>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).</p>
  <p>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.</p>
  <p>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.</p>
  <p>I'm hoping someone has ideas about why the second site's cache files are not updating.</p>
  <p>Thanks in advance :).</p>
  
Tags: <cache><plugin-blitz>
Title: Blitz not updating cache on multi-sites
ThreadText: # Blitz not updating cache on multi-sites
  
  (Asked by: username_0 on 2023-03-22)
  
  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 :).
  
  **Tags:** cache, plugin-blitz
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2023-03-26. Score: 1 | Accepted answer
  
  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.
  
  
  ---
  
  ### Answer by username_1 on 2023-03-22. Score: 1
  
  Just in case, make sure that your second site [is included for the cache pattern](https://i.sstatic.net/Wsn5O.png)
  
  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>
  
  > **Comments:**
  > **username_0**: Thanks @username_1 . 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  
  > **username_1**: Okay, do the easiest trick. Create an empty template and open it on the problem site, will this page be cached?  
  > **username_0**: 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.  
  > **username_1**: Sounds really weird. You can ask Ben Croker for the help https://github.com/putyourlightson/craft-blitz/issues  
  > **username_0**: Thanks @username_1 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.  
  
  ---
  
  