nystudio107 / craft-seomatic

SEOmatic facilitates modern SEO best practices & implementation for Craft CMS 3. It is a turnkey SEO system that is comprehensive, powerful, and flexible.
https://nystudio107.com/plugins/seomatic
Other
165 stars 70 forks source link

Add hreflang Tags in combination with blitz caches all pages instead of only the one requested #1195

Closed WHITE-developer closed 2 years ago

WHITE-developer commented 2 years ago

Describe the bug

We have a multi-site (multi domain) (7 sites) craft setup with Blitz and Seomatic installed. The blitz cache generation is set to Clear the cache, regenerate manually or organically but when we request a single page Blitz is trying to cache all the other sites as well. We narrowed it down to the hreflang tag setting in Seomatic. We disabled all plugins and a complete empty page and when we enabled this tag setting we got this behavior.

So it looks like this hreflang tag is crawling all the sites?

To reproduce

Steps to reproduce the behaviour:

  1. Have a multi-site craft installation with blitz and seomatic
  2. Set blitz cache generation to Clear the cache, regenerate manually or organically and enable the hreflang tags in Seomatic
  3. Blitz is now caching the page for all sites what is throwing a nginx timeout

Versions

khalwat commented 2 years ago

SEOmatic's hreflang tag does not crawl the site or make additional external requests.

Here's the code path: https://github.com/nystudio107/craft-seomatic/blob/a7fe6c9af0b9a183606ca7b7d05c1e640cad8355/src/helpers/DynamicMeta.php#L427

It's possible something SEOmatic is doing is triggering Blitz for some reason, and I'd be happy to work with @bencroker on that, but I think this likely will be a Blitz-related issue.

Although SEOmatic never crawls pages, if you make a change to an entry, it will ping search engines to notify them that the page has changed. I think it'd be unlikely that this is the cause, tho, because search engines rarely index immediately.

Something to look at, though. See if you can find:

WHITE-developer commented 2 years ago

Regenerating cache on save is disabled it only clears it and then organically generates it's back. And the request are coming straight from my browser.

khalwat commented 2 years ago

Can you show me the request log?

I went through the code path in SEOmatic, and don't see anywhere that it ever issues a request for web pages.

@bencroker ?

bencroker commented 2 years ago

My guess would be that perhaps something is triggering the MetaContainers::EVENT_INVALIDATE_CONTAINER_CACHES event, which the SEOmatic integration in Blitz listens for, and which subsequently kicks off a cache refresh. https://github.com/putyourlightson/craft-blitz/blob/develop/src/drivers/integrations/SeomaticIntegration.php

khalwat commented 2 years ago

SEOmatic is likely triggering that event as a result of the elements being saved. I guess it re-saves each site's localized element when an entry is changed, even if the change is only made to a single site.

Probably it has to do this, because of the flexibility of propagation methods, you can't be sure that a change to one site's entry does not affect the others.

bencroker commented 2 years ago

That's what I'd assume, but according to @WHITE-developer this is happening on page view (not entry save), and with Blitz set to clear only (not regenerate), is that correct and does this help to shed any light on the issue so far?