Conversation
|
Okay, so... this is really difficult for me. There's nothing strictly wrong with this pull request. The code is well done and you considered the situation and implications well with the config, VCL, and data section handling. I would ask for strict_types declarations and declaring all the dependencies in composer + module.xml. But I have two PRs for bfcache here, and I think #5 is a better starting point given its config and JS/UX aspects. I'm going to move forward on processing #5 unless anything goes amiss. Would appreciate your input as well, if you're up for it.
|
|
Hi @rhoerr |
|
Thanks @dadolun95. I'm open to improvements on any of that, wherever it makes sense. A comment from @JaJuMa on VCL #5:
For further discussion. |
|
I lean toward including out of box VCL updates as this proposes. Overall it seems like something that should probably change in the core VCL template directly (with possible connection to https://github.com/mage-os/mageos-magento2/pulls?q=is%3Apr+is%3Aopen+vcl and/or https://github.com/elgentos/magento2-varnish-extended per Discord -- thanks @sprankhub and @dadolun95 ) -- but I want to see this available to any Magento instance that installs this module, too, if at all possible. VCL customizations shouldn't be a direct concern, I think?, as this should only impact new VCL configuration files generated by Magento. But I don't generally use Varnish and don't have experience with it on various hosting environments or configurations. Please educate me here if this does introduce risks. |
|
Just throwing in my two cents. I do the varnish changes very similar to how they're done in the elgentos module here In fastly I have a snippet like if (resp.http.Cache-Control !~ "private" && req.url !~ "^/(media|static)/" && fastly_info.state ~ "HIT") {
set resp.http.Cache-Control = "must-revalidate, max-age=60";
}In both these cases we have rules that read like "if the request is not private, not an asset, and is varnish cacheable" then "it's eligible for bfcache". The rationale being, if it was going to be a page load served by varnish anyway then it was already cacheable and shareable, so knock yourself out and use bfcache. To me this is better than building some exclusion list, as you only have one ruleset for what is cacheable and it's the same for a "navigation" as well as a "back/forward". There's already rules in place for the checkout etc to make them not cacheable. This makes it a bit safer, as the same rules that are in place to determine whether a page is cacheable applies for both navigations as well as back/forward. |
|
Just a few clarifications on the current bfcache implementation: The current implementation is not about maintaining an exclusion list.
These safeguards are essential regardless of the backend cache used. Regarding the VCL snippetThe suggested version may not be the best fit, because:
A safer approach that more closely mirrors the backend logic would be: sub vcl_deliver {
// Update following line: //
set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
// To: //
if (resp.http.Cache-Control ~ "public") {
set resp.http.Cache-Control = "no-cache, must-revalidate, max-age=0";
} else {
set resp.http.Cache-Control = "no-store, no-cache, must-revalidate, max-age=0";
}
}Regarding the original question discussed here about including bfcache logic in .vcl generationThe main considerations from my point of view are operational:
|
|
Thanks @JaJuMa, for clarity the fastly and VCL examples were merely examples on how customisation can be applied by looking at the main caching rules. Not recommendations of how to implement here, there's no way a fastly snippet would be applicable here. A lot of the feedback you posted above seems to pertain to the work implemented in #5, which seems sensible. You say
but the work in this PR does seem to specifically be looking at a code defined <excluded_paths>checkout|cart|customer|wishlist|downloadable|sales|vault|review|newsletter</excluded_paths> |
|
@convenient Thanks for clarifying 🙏 I think the confusion here comes from PR #5 already being merged, which I was referring to as the “current implementation,” while PR #2 is still open due to the discussion about whether or not to include VCL generation logic for bfcache, and how. That’s why my earlier comments may have sounded broader. Hope that clears it up a bit! |
|
No problems @JaJuMa , I did have to take a second look at this PR because I thought I missed a LOT of functionality somehow 😅 I haven't had time to read your initial work in detail, but maybe some flag or something can be set on the response for the VCL to look at, rather than this coded list? Just an idea. It would be good to avoid having multiple "exclude" lists. |
|
Thanks! From my understanding, the open discussion here is mostly about the Regarding your question:
That’s a great suggestion, and it’s actually how the module (as in current |
In which case, the entire additional "exclude" functionality can be removed from this PR, as it will be driven by the definitions and the additional "optional exclude" that was already introduced in #5 ? |
|
Hi guys, In my point of view the vcl generated by admin must be congruent with any configuration made on admin that should impact varnish. So speaking about bf-cache, if a site uses varnish proxy with auto-generated vcl by magento default will not work due to the vcl_deliver instruction provided by magento templates. This PR is a draft of what we need to make in order to see bf-cache working with varnish updating vcl generation by admin also. So we can close this PR and ignore it but I think that vcl generation should be managed somehow and I think that the module previously mentioned is the more advanced opensource solution for that right now. |
|
I agree that the elgentos/magento2-varnish-extended module is a great initiative for improving the default VCL. We’ve even used parts of their work as inspiration before. When it comes to pulling it in as a dependency for this module, though, there are a few considerations:
So while elgentos’ work is very valuable (and definitely worth recommending), my concern is that adding it as a dependency here might introduce more complexity - and risk - than it solves. Given these points, doesn't it seem that referring to a tested VCL snippet in the docs (like the one mentioned above that cleanly mirrors the module's backend logic) would be a simpler and safer way to help Varnish users, while keeping this module itself focused solely on BFCache? |
|
Thank you all for your input. Okay, let's do this:
@JaJuMa in the interest of time, if you agree, could you make these changes in a new PR? I'd like this wrapped up in the next week, and Davide has some other modules/issues to handle. @dadolun95 Is that good with you? Is there anything else you feel we need to address still? |
No description provided.