Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

2 Answers 2

up vote 4 down vote accepted

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 ...

share|improve this answer
    
Thank you for the help –  Vladimir Oct 3 '12 at 13:41

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.