eZ Platform Discussions

Http Cache Varnish

Currently I use ezPlatform enterprise, I have varnish in local docker and I activated the cache under my siteaccess.

  content:
      view_cache: true      # Activates HttpCache for content
      ttl_cache: false
      default_ttl: 20

I dont understand why the cache -control header is not correctly interact. When I load the page for the second time I feel the power of the cache. I seems work. Bu the cache control header is not synchronized. It tell me there’s no cache.

`X-Varnish: 327749 360501`
`Age: 4`
`Via: 1.1 varnish (Varnish/5.2)`
`Vary: Accept-Encoding`
`cache-control: private, no-cache, no-store, must-revalidate`
`X-Cache: HIT`
`X-Cache-Hits: 1`
`X-Cache-TTL: 55.142`

Hi Fabien,

This because the default VCL is forcing the cache to be private when delivered from Varnish, IF you are logged in with a user account (and not anonymous user), AND if the response varies by user hash (user permissions) which most responses does in eZ Platform.

There are two reasons for this:

  • eZ Platform currently uses s-maxage, aka setSharedMaxAge(), however this is only meant for the reverse proxy (Varnish, Fastly or Symfony Proxy) which we can purge, not for other internet proxies in-between server and client.
  • We also got concerns from some partners that by default they’d like that logged in users data is never cached in browser (normal maxage header) for security reasons when involving shared computers

So, this is why the default VCL is doing this, and you can change it if your site has different requirements. That is the nature of VCL, and other configurations.

It’s being done in the following section: