FOSHttpCacheBundle icon indicating copy to clipboard operation
FOSHttpCacheBundle copied to clipboard

Add a command to generate a varnish vcl file based on current configurations and listeners

Open alexander-schranz opened this issue 2 years ago • 1 comments

Based on the bundle configuration (user_context_hash, xkey, ...) and registered http cache subscribers (e.g. CustomTtlListener, UserContextListener, ...) it would be greate to generate the .vcl file.

Specially in cases like https://github.com/FriendsOfSymfony/FOSHttpCache/issues/496 reported by @bastnic. The FOSHttpCacheBundle could provide performant vcl for the current configuration.

alexander-schranz avatar Sep 29 '21 17:09 alexander-schranz

i fixed the VCL snipped we provide in https://github.com/FriendsOfSymfony/FOSHttpCache/pull/497 but got sidetracked because the CI had rotted and i started the switch to github actions. that is https://github.com/FriendsOfSymfony/FOSHttpCache/pull/500 which i did not get around to figure out yet because live happened...

FOSHttpCache provides the various VCL snippets you need - the performance fix needs to be done in those snippets, adding a command here does not solve that problem.

however, there is value in your idea. such a command would make it easier for new users to get started without having to figure out which snippets exactly they need.

my idea for the snippets is that you use VCL to include the individual files to keep the main VCL small and clearly visible which parts are written by the user and which are the snippets provided by FOSHttpCache. this makes it easier to follow upgrades, e.g. the context hash performance optimization that you mentioned.

if you want to work on such a command, i'd suggest we generate a very barbone VCL that references the snippets that you need and calls the methods as necessary to make varnish work with the symfony configuration. we could put all that into a build folder and also copy the snippets there so people can just use the build folder as a starting point for varnish.

dbu avatar Sep 30 '21 06:09 dbu