Micro-caching and Nginx can really speed up the app. Would it be possible to use micro-caching (or something similar) with Varnish?
-
Can you be a bit more specific? – ivy Sep 28 '12 at 19:01
1 Answers
Yes you can set Varnish to micro-cache content.
For other readers, micro-caching is a transparent process where a cache keeps a local of copy of content that is not to be cached, and serves that for a specified time.
For example, you may have a home page the updates often, and have no caching set in the headers for the site. However your application is running on a VM that is low performance, and it cannot cope with many requests. Micro-caching can mitigate this problem by silently serving the home page from cache (and sending no headers) for a short time.
In Varnish this is achieved with the TTL setting. This tells varnish to cache the content for the time specified.
If you are using TTL you should also use the GRACE setting - this tells varnish to continue to serve cached content for a specified time should the backend not respond in a timely manner.
The other advantage with TTL (the default is, I believe, 120 seconds) is that varnish sends only the first request for uncached content to the backend, queuing any other requests to wait for the cache to be ready.
The Varnish Book has some examples of what is possible with various settings of grace and ttl.

- 10,383
- 2
- 33
- 37