mirror of
https://github.com/cloudpanel-io/cloudpanel-ce.git
synced 2026-04-05 20:31:58 +02:00
Issue with Varnish Cache and different browsers #156
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rsmith4321 on 12/6/2024
CloudPanel version(s) affected
2.5.0
Description
The varnish cache settings cause issues where Chrome and Safari create separate cache. You can see this in the x-cache-age header times being different for both.
How to reproduce
Visit cached pages in different browsers
Possible Solution
This change to the default.vcl file seems to fix the issue. Please check it out and possibly merge the change.
Just replace the block
if (req.http.Accept-Encoding) { if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") { # No point in compressing these unset req.http.Accept-Encoding; } elsif (req.http.Accept-Encoding ~ "gzip") { set req.http.Accept-Encoding = "gzip"; } elsif (req.http.Accept-Encoding ~ "deflate" && req.http.user-agent !~ "MSIE") { set req.http.Accept-Encoding = "deflate"; } else { # unknown algorithm unset req.http.Accept-Encoding; } }withif (req.http.Accept-Encoding) { # Files that don't benefit from additional compression: if (req.url ~ "\.(jpg|jpeg|png|gif|gz|tgz|bz2|tbz|mp3|ogg|swf|flv)$") { # No point in compressing these further unset req.http.Accept-Encoding; } else { # Otherwise, force gzip if supported, unset if not if (req.http.Accept-Encoding ~ "gzip") { set req.http.Accept-Encoding = "gzip"; } else { unset req.http.Accept-Encoding; } } }and Chrome and Safari will use the same page cache. You can check the x-cache-age headers and they sync up. It might even be better to enable br support instead of just gzip but I didn't want to complicate things, I know br isn't natively supported by Varnish.Additional Context
No response