Public Repository

Last pushed: 3 months ago
Short Description
Varnish 4 customized for Symfony
Full Description

Varnish 4 And Symfony Caching Strategy

Request Headers

Details to come...

Response Headers

  • We have decided to only support the Cache-Control headers because "expires" is out-dated.
  • Varnish will only cache a response if the Cache-Control header is public.
  • The Age header is how long varnish has had the object in cache. If the value were 60, this would mean that 60 seconds has passed, since it was first cached.

Cache-Control Examples:

For a detailed expolnation of Cache-Control headers.

"Public" tells Varnish that it's ok to cache, vs "private", which means only the browser can cache it. If "public" is sent without max-age or s-maxage headers, varnish will cache the request for the default ttl of 3600 seconds.

Cache in the Browser and Varnish.

  • This will cached in the bowser and Varnish for 1 minute.

      Cache-Control:max-age=60, public

Cache in the Browser different from Varnish.

  • This will cached in the bowser for 1 minute and Varnish for 5 minutes.

      Cache-Control:max-age=60, public, s-maxage=300

Cache only in Varnish.

  • This will cached in the bowser for 0 minute and Varnish for 1 minutes.

      Cache-Control:public, s-maxage=60

Cache only in the broswer.

  • This will cached in the bowser for 1 minute and Varnish for 0 minutes. This is because private tells Varnish not to cache it.

      Cache-Control:max-age=60, private

Grace Mode

Grace mode allows you to instruct Varnish to keep an object in cache beyond its TTL and serve this stale content if your backend is not healthy or if fresh content hasn’t been fetched yet.

Docker Pull Command