Issue with Varnish Cache and different browsers #156

Closed
opened 2026-04-05 20:25:36 +02:00 by MrUnknownDE · 0 comments
Owner

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; } } with if (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

*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; } }``` with ```if (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_
MrUnknownDE added the improvementimprovementimprovementimprovement labels 2026-04-05 20:25:36 +02:00
Sign in to join this conversation.