Reputation: 2895
I try to create a regex for varnish cache v4
sub vcl_backend_response {
if (bereq.url ~ "(/media|/bundles|/sonata_admin/|/build)$" ) {
{
unset beresp.http.set-cookie;
set beresp.http.cache-control = "public, max-age=2592000";
set beresp.ttl = 30d;
return (deliver);
}
also I try
if (bereq.url ~ "(\/media|\/bundles|\/sonata_admin|\/build)$" ) {
I want to include all files where location starts from /media or /bundles or ...
this not work
Upvotes: 0
Views: 929
Reputation: 9845
In your config, it doesn't work because you're matching up with $
that stands for "at the end of string".
You want to use ^
which is "match at the beginning", thus:
if (bereq.url ~ "^/(media|bundles|sonata_admin|build)") {
unset beresp.http.set-cookie;
set beresp.http.cache-control = "public, max-age=2592000";
set beresp.ttl = 30d;
return (deliver);
}
Upvotes: 3