Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Cache tags not getting added to responses when content is within {% cache %} twig tags #61

Open
RedLucas opened this issue Feb 12, 2022 · 4 comments
Milestone

Comments

@RedLucas
Copy link

I've noticed that only get generated and added to the response headers (in my case Cloudflare Cache-Tags) when the Response is a cold cache.

So on first load, the response has all necessary CacheTags headers, but it's possible that the cloudflare cache will be cleared for reasons.

Since Craft's template cache is caching content, any entries that were loaded within the {% cache %} tags no longer get added to the response headers.

I'm seeing this on CraftCMS 3.7.32 and Upper 1.9.1.

I'm not sure that this was always a problem, but perhaps it's a new problem from the 3.7 update?

@ostark
Copy link
Owner

ostark commented Feb 14, 2022

I guess it was always like this. 🙉
To me, it makes sense to use the Craft/twig template cache and the full-page-cache Upper provides.

I need to investigate the behavior.
Hopefully, there is an easy way to deliver cache tags even if you use the {% cache %} tag.

@ostark
Copy link
Owner

ostark commented Feb 14, 2022

It's very possible!

@ostark ostark added this to the Next milestone Jun 1, 2022
@khalwat
Copy link

khalwat commented Jun 16, 2022

You can use Craft's new-ish (as of 3.5) built-in functionality for collecting element cache tags via Elements::startCollectingCacheTags() / Elements::stopCollectingCacheTags() to get a list of tag dependencies for a rendered template

@khalwat
Copy link

khalwat commented Jul 18, 2022

Related PR: craftcms/cms#11617

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants