Skip to content
This repository has been archived by the owner on Sep 16, 2021. It is now read-only.

integrate FOSHttpCache with the CMF #211

Open
4 tasks
dbu opened this issue Oct 27, 2014 · 6 comments
Open
4 tasks

integrate FOSHttpCache with the CMF #211

dbu opened this issue Oct 27, 2014 · 6 comments

Comments

@dbu
Copy link
Member

dbu commented Oct 27, 2014

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:

  • Where do we place which of this code? Some might fit into FOSHttpCacheBundle (generic doctrine integration), other belongs either into CmfCoreBundle or do we need a CmCacheBundle?
  • How to build the CmsInvalidator (without doing a horribly complicated overengineered thing)
  • Do we do anything about cache tagging?
  • Do we miss anything here?

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.

@phiamo
Copy link

phiamo commented Oct 27, 2014

@dbu thanks a lot! need to test this and then could give some more input

@dantleech
Copy link
Member

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?

cmf_cache:
    documents:
        Acme\BlogBundle\Post: post.invalidator # ID of service

@dbu
Copy link
Member Author

dbu commented Oct 27, 2014

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).

@dbu
Copy link
Member Author

dbu commented Oct 27, 2014

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.

@dbu
Copy link
Member Author

dbu commented Dec 13, 2014

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.

@dbu
Copy link
Member Author

dbu commented Dec 17, 2014

early tag support and a basic twig function will be added in FriendsOfSymfony/FOSHttpCacheBundle#182

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

No branches or pull requests

3 participants