Symfony Nelmio Framework Extra Bundle cache config by notation is being override on browser

When I set cache by notation on any controller of my symfony proyect:

/**
 * @Cache(smaxage="301", maxage="300", public=true)
 */
public function fooAction(Request $request)
{
    [...]
}

max-age and public options are override when they reach the browser:

Response headers
Cache-Control: max-age=0, must-revalidate, private, s-maxage=301
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=UTF-8
Date: Fri, 10 Jan 2020 13:12:46 GMT
Expires: Fri, 10 Jan 2020 13:12:46 GMT
Server: nginx
Transfer-Encoding: chunked
Vary: Accept-Encoding
X-Content-Type-Options: nosniff
X-Debug-Token: da1477
X-Debug-Token-Link: http://proyect.local:8080/_profiler/da1477
X-XSS-Protection: 1; mode=block

Symfony profiler although gets all the settings properly:

Symfony profiler

I’m trying to find why without any success. Those are things that I already tried:

  • Server is Nginx and has no default cache config.
  • This is happening in local environment, but also in prod, so no CDN is enabled.
  • Tried different syntax: @Cache(expires=”+2 days”)
  • Disabled fos_rest

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *