eZ Platform Discussions

Just to remind everybody about the importance of caching


#1

We had a great workshop about HTTP Caching with Varnish at the Web Summer Camp

I suggest to check the slides, we will hopefully soon share the video as well.


#2

Slides are really nice, I have just read them.

I would add few things, (let me know if you agree)

  • prefer Varnish 4 and even 5 when possible.
  • prefer expiration model and long TTL rather than validation model (to avoid hitting the backend all the time). eZ provides everything to purge it would be sad not to use it.
  • webservers are usually adding headers automatically (default configuration) like E-tag, Last Modified etc. usually for assets, I usually add by default the following
    sub vcl_backend_response {
    if (bereq.method == "GET" && bereq.url ~ "\.(gif|jpg|jpeg|bmp|png|tiff|tif|ico|img|tga|wmf|wofsvg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmvf)$") {
            unset beresp.http.expires;
            unset beresp.http.etag;
            unset beresp.http.last-modified;
            set beresp.http.cache-control = "max-age=864000";
            set beresp.ttl = 50d;
        }
}

I would do the same for bereq.url ~ "\.(css|js|html)$" with different TTL.

  • 50d in Varnish but it could be forever,
  • 10d in Browser cache but it could also be forever, it depends (you could want to make a difference between assets and images related to contents)

Also, it might worth looking to the new value: immutable, example: Cache-Control: max-age=365000000, immutable


#3

Oh, yes, there is plenty to discuss here. The workshop was more general about Varnish integration and just a bit of eZ specific stuff. I think the community needs to know the HTTP Cache basics well as its quite important part of the new stack.

Regarding few of your comments:

  • Varnish 4 or 5? Yes, of course
  • Invalidation by purging? Yes, it will be even better with newer versions of FOSHttpCache and xkey
  • Cache assets and media files? Yes, but sometimes if you have gigabytes of content images you might not want to spend all of your Varnish cache on these statics

#4

Lately, we have been using external (cloud) image providers like Cloudinary, meaning one less thing to worry about in Varnish VCL :slight_smile:


#5

P.S. In 2015 on Summer Camp, there was also a workshop about Varnish:


#6

Here is the recorded video from the Web Summer Camp 2017 workshop on HTTP Cache: https://www.youtube.com/watch?v=rfnXaiRWepQ by David from Liip and Hrvoje from Netgen.