Follow-up to #2752961-157: No reliable method exists for clearing the Twig cache
Problem/Motivation
@Fabianx' post:
I am still of the opinion this should have used cache tags instead.
However cache tags could be used in addition as the main thing is the addition of the invalidate method.
e.g. my proposal for a follow-up:
- Inject cache_tags.checksum
- Use 'twig-templates' cache tag
- Calculate the checksum
- Use the checksum as "cs[NUM]-" prefix before the actual uniqid prefix
- Use Cache::invalidateTags(['twig-templates']); as invalidation method instead of deletion of the state
- Hosting providers can just watch for the invalidation of 'twig-templates' cache tag and do a clean-up job for the previous checksum
- Hosting providers can check if the checksum is valid during garbage collection
- Even without monitoring garbage-collection is dead-easy as checksums for an individual cache tag will currently be always increasing
Comments
Comment #1
Anonymous (not verified) commentedvaplas created an issue. See original summary.
Comment #7
rgpublicI wonder: Shouldn't there be separate cache tags for each *.twig file? That would feel a lot more "Drupaly". Usually I would expect that I can invalidate some tags if only some files have changed. Isn't that what the cool cache tags feature of Drupal is all about? To avoid the usual all or nothing approach with caching?