-
Notifications
You must be signed in to change notification settings - Fork 94
integrate FOSHttpCache with the CMF #211
Comments
@dbu thanks a lot! need to test this and then could give some more input |
So does that Gist provide two mechanisms for invalidating the cache (cron and event listener?). Why can we not invalidate the unpublished documents via. an Event listener? I would place this in a CmfCacheBundle. For the mechanism, what about providing mappings?
|
about the command: there is no event for when content is no longer considered published or starts being considered published because time marches on. that command would need to run rather often (depending on how exact you want your publishing to happen). |
the configuration with services sounds like a good idea. then we can have generic services like RouteInvalidator that works on any route thing and ParentInvalidator to recurse onto the parent. |
so we will call this SymfonyCmfHttpCacheBundle we provide a twig extension for {% cmf_cache_tag cmfMainContent, "something" %}, so you can pass in a string that is added to the tags or pass an object where we extract the id via doctrine. |
early tag support and a basic twig function will be added in FriendsOfSymfony/FOSHttpCacheBundle#182 |
The FOSHttpCache and FOSHttpCacheBundle provide integration between symfony and http caches like varnish, nginx or the built-in symfony cache.
We should integrate this with Doctrine and the cmf. I created this gist: https://gist.github.com/dbu/67c838a2002ff667eacb showing a rough draft of how this can look. The CmsInvalidator class is the most complex one, and you would need to extend that for your project. We need to find a way there to not have to copy-paste the basic things but keep enough flexibility.
This aproach is not using cache tagging but assuming that invalidating the main content, or the parent main content of a block, is good enough. If we have more complex mixed content, we would want cache tagging. Here i wonder if we should have a twig function in FOSHttpCacheBundle to add a cache tag to a response. At least in the CMF context, the template is the easiest place to detect that something actually is rendered. Alternatively, the block context could know about caching and add the tag when asked to render. This still does not help for a page that e.g. lists children of a document or other things that do not go through a block context.
Questions to discuss:
Another topic is caching headers from the content but i am really unsure if a generic thing makes sense here. If its not just the main content but also blocks and whatnot, it gets really complicated to determine the correct headers. As the FOSHttpCacheBundle only provides cache header rules by path (which works fine with the cmf already) i propose to discuss that topic in a separate issue at another time.
The text was updated successfully, but these errors were encountered: