Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newly added entries do not clear template cache which contains an entry query #2959

Closed
bendesilva opened this issue Jun 5, 2018 · 6 comments

Comments

@bendesilva
Copy link

Description

A new entry created in a {% cache %} wrapped entries query (paginated or otherwise) does not clear the template cache as expected. Updating or deleting an existing entry within the same query does clear the cache.

Steps to reproduce

  1. Create a new entries query in a template.
  2. Wrap in {% cache %} tags.
  3. Create new entry which should appear within the query.
  4. Cached template does not update.
  5. Delete or update another entry within the same query.
  6. Cached template does update, new entry is seen.

Additional info

  • Craft version: 3.0.9
  • PHP version: 7.1 & 7.2
  • Database driver & version: MySQL
@bendesilva bendesilva changed the title New entries added to a query does not clear template cache Newly added entries do not clear template cache which contains an entry query Jun 5, 2018
@brandonkelly
Copy link
Member

The template cache should get cleared by the “Delete stale template caches” background task. Is that running and completing for you, after saving the new entry?

@bendesilva
Copy link
Author

@brandonkelly Yes, the task runs and I can see it completing in the CP. For context I had this happen on a production site and managed to replicate across two other development sites and a fresh install of Craft 3.0.9. Also just tried a fresh install of 3.0.8 and it works fine, so looks like something in this latest version?

@brandonkelly
Copy link
Member

Gotcha, thanks! Fixed now in 3.0.10.1 :)

@itsmattsoria
Copy link

@brandonkelly — I'm actually experiencing the exact same issue @bendesilva described on Craft 3.4.19.1, the exact same flow:

  1. Create a new entries query in a template.
  2. Wrap in {% cache %} tags.
  3. Create new entry which should appear within the query.
  4. Cached template does not update.
  5. Delete or update another entry within the same query.
  6. Cached template does update, new entry is seen.

Craft v 3.4.19.1
PHP 7.4.1

@brandonkelly
Copy link
Member

@poopsplat When a new entry is added, it’s up to the “Deleting stale template caches” background job to find any caches that should be deleted as a result, which can take some time to complete depending on the number of caches it has to go through, and how many entry queries they each contained.

If you want something more immediate, check out the Cache Flag plugin. Or take a look at Blitz for full template caching, if your site doesn’t need to be dynamically generated for the most part.

@itsmattsoria
Copy link

@brandonkelly — that makes sense, and thanks for the recommendations! 🙏

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

No branches or pull requests

3 participants