-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Adds support for purging varnish cache based on an X-Pool header #4106
Adds support for purging varnish cache based on an X-Pool header #4106
Conversation
@davidalger can you please resync with develop and restart builds? |
6852c42
to
daddb88
Compare
@mazhalai Rebased on latest develop. Let me know if you need anything else. |
@davidalger we have created ticket MAGETWO-52293 to process this PR. |
@maksek can we process it? |
I tried googling for x-pool http header to see if this technique was used by others and didn't see any reference to this header. I want to understand the use case a little better. Is the purpose to configure a sets of upstream http servers with different x-pool headers so that you can flush the caches produced by different sets of servers? Or tag the cache with version / deploy numbers so you can flush the cache associated with the previous deployment code? |
@bwaters Theoretically this could be used to accomplish nearly any varnish flushing behavior one desired, as it's value is entirely controlled by the server configurations, allowing a lot of flexibility in what one is flushing. This introduces a flexibility into the standard VCL so that publicly available tools can work completely with out-of-the-box configuration files. Support for using this has been built into the davidalger/capistrano-magento2 gem which I've built and released for public use. It's not quite yet documented in the readme for the gem yet, but the support is there to set the As for how I am specifically using it: We are using it to ban everything related to a specific site from the varnish cache when the deploy is complete. The Nginx server configuration is using an Regarding the X-Pool header not being found around the web…no, it's not a "standard" header name. It's a custom header just like the ones which Magento uses to tag it's responses for tag based varnish flushing, but in this case, it's application agnostic, and more relatable to the X-Server header in that it's identifying a sub-set of what is being served up by a given server and/or group of servers. I'm really looking forward to seeing this merged in! |
+1 I'm also interested in seeing an @davidalger You might be interested to check out this somewhat related pull request #4905 |
Can |
@buskamuza Sorry, I either did not see your question until now or it slipped by me…last few months have been crazy over here!
In short, no, not really. Modifying that header with Nginx would be difficult, and wouldn't be something which would then serve the sole purpose of identifying which "pool" served the request.
You are correct that it's not used by Magento itself. This is a VCL file though, and closely related to server configuration. It is needed to support the increasingly widely used Capistrano based deployment setup using the capistrano-magento2 gem. There is functionality in this gem which I've been holding off on documenting until this PR is merged in. Folks are already trying to use the undocumented functionality in the deploy tool and finding that the VCL built-in to Magento 2 does not support the X-Pool header needed for the tool to flush varnish by pool to work. As for me personally, I don't use the stock VCL anymore, as things like this not being merged in have forced me to maintain my own VCL for M2 hosting setups. Please consider getting this simple enhancement merged in! |
+1 vote for adding this to the default Magento VCL. @buskamuza One of the beautiful things about M2 being an open-source project is that if developers are curious about the origin of a section of code, they can always run a |
@davidalger , sorry, looks like I missed your answer too. |
@buskamuza I will add comments. Thanks! |
@davidalger the change looks awesome! Can you please update the source code? Magento does not have vanish3.vcl in the mainline, instead, there is varnish5.vcl |
…the X-Pool header
daddb88
to
843c832
Compare
@vrann I've just rebased on develop and updated to affect the varnish5.vcl vs the old v3 config file. Also added a comment to each file as @buskamuza had requested. Let me know if anything else is needed to see this merged in. Thanks! |
@davidalger perfect, thanks, will be merged. |
[TSG] MFTF for 2.3 (pr14) (2.3.2)
This adds the ability to default vcl templates to issue PURGE requests using an X-Pool header instead of the various headers Magento sets on it's responses.
Use case is flushing a specifc "pool" of cache records during automated deployments. It would be expected that the X-Pool header would be set in the Apache/Nginx config files if used.