cms icon indicating copy to clipboard operation
cms copied to clipboard

Static cache not invalidated for multisite

Open stuartcusackie opened this issue 3 years ago • 2 comments
trafficstars

Bug description

I have a blog collection and entries are localised. I'm noticing that my Static Cache Invalidation rules work for my default site, but not for my subsites.

The problem occurs on my blog index page: /blog

If I unpublish an entry from the default site then it disappears from the index on the default site but if I unpublish the same entry from the subsite it remains on the blog index on the subsite.

My cache invalidation rules are like so:

'rules' => [
  'collections' => [
    'blog' => [
      'urls' => [
        '/blog'
      ]
    ],
   .....

I'm using blade and this is how I retrieve entries for the blog index:

@php($tag = Statamic::tag('collection:blog')->paginate(12)->sort('date:desc')->as('articles')->fetch())

I have tried 'rules' => 'all' and it works so this seems like a bug to me. I can't see any problems with my rules.

How to reproduce

Not sure. Set up a multisite collection and unpublish the article from each site to see if it's outputted on your collection index page.

Logs

No response

Environment

Laravel Version: 9.22.1
PHP Version: 8.1.1
Composer Version: 2.2.3
Statamic Version: 3.3.24

Installation

Fresh statamic/statamic site via CLI

Antlers Parser

No response

Additional details

No response

stuartcusackie avatar Jul 29 '22 13:07 stuartcusackie

What if you add /subsite/blog to the list of URLs?

jasonvarga avatar Jul 31 '22 20:07 jasonvarga

My site names are ie (primary) and uk.

I have added the urls below to the invalidation rules but it still only works on my primary domain:

'blog' => [
  'urls' => [
    '/blog',
    '/uk/blog',
    '/subsite/blog',
    '/uk.mysite.test/blog',
    '/mysite.co.uk/blog'
  ]
],

stuartcusackie avatar Aug 04 '22 08:08 stuartcusackie

Would you be able to provide config/statamic/sites.php?

jasonvarga avatar Sep 05 '22 16:09 jasonvarga

config/statamic/sites.php (actual site name replaced)

'sites' => [

        'ie' => [
            'name' => 'website.ie',
            'locale' => 'en_IE',
            'url' => config('app.url'),
        ],

        'uk' => [
            'name' => 'website.co.uk',
            'locale' => 'en_UK',
            'url' => config('app.url_uk'),
        ],

        'com' => [
            'name' => 'website.com',
            'locale' => 'en_US',
            'url' => config('app.url_com'),
        ],
        
    ],

ENV VARS

APP_URL=https://www.website.ie
APP_URL_UK=https://www.website.co.uk
APP_URL_COM=https://www.website.com

Please note we are intentionally using www in the urls for this project.

stuartcusackie avatar Sep 05 '22 19:09 stuartcusackie

The ie and com sites have the same url in the env file. Is that correct?

jasonvarga avatar Sep 05 '22 20:09 jasonvarga

@jasonvarga No, sorry. I made a typo when redacting the actual site name. I've updated it now.

stuartcusackie avatar Sep 06 '22 09:09 stuartcusackie

This one is still a problem I am afraid. Statamic 3.4.*

stuartcusackie avatar Feb 02 '23 11:02 stuartcusackie