2

Micro-caching and Nginx can really speed up the app. Would it be possible to use micro-caching (or something similar) with Varnish?

2 Answers 2

4

If your going to go to the lengths of caching the dynamic response - even for 1 second - you'll need to make sure the data you are caching is safe to cache.

Ie. Doesn't contain any session/user specific data

And once you've done that - you may as well have the cache last until the point where it has to be invalidated/expire. So the benefits of doing what you describe don't really exist.

Either the data is safe to cache without any app modification (ie. won't contain cart contents/user information etc.) - in which case, you could just enable indefinite caching until the next purge ... or ... you have to re-code your app to ensure it only sends "cacheable" headers when the data can be cached - and edit your VCLs so that the cached session is invalidated when necessary.

The only time I can think it could be suitable is for vanity testing RPS with ab or siege ...

0
3

If by micro-caching you mean very low ttl. Then yes. Varnish can do that.

For Varnish 3.x:

in sub vcl_fetch() at the end of function (or at other logical place):

set beresp.ttl = 1s;

And remember about "shortlived" parameter (default 10s). Objects created with TTL shorter than this are always put in transient storage. By default Varnish would use an unlimited malloc for transient storage.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .