I would like to set up Varnish as reverse proxy cache for Apache.
How can setup Varnish so that Varnish should serve all static data (jpeg, jpg, png, gif, ico, js, css, txt, pdf, gz, zip, lzma, bz2, tgz, tbz, webp, html, htm) and A dynamic pages should be handed to Apache)
The only suggestions I have seen so far, are some variation of putting all my static content in a different place (e.g. subdomain) from the dynamic content. This seems odd, even ridiculous. Eitherway, that's not really an option.
Would something like this help?
if (req.url ~ “\.(jpeg|jpg|png|gif|ico|webp|js|css|txt|pdf|gz|zip|lzma|bz2|tgz|tbz|html|htm)$”) {
return (lookup);
} else {
return (pass);
}