I
I
Ivan Antonov2016-11-14 14:53:30
symfony
Ivan Antonov, 2016-11-14 14:53:30

How to set up Cache-Control in Symfony?

Specified cache lifetime in .htaccess

<IfModule mod_expires.c>
  ExpiresActive On
  ExpiresDefault "access plus 1 seconds"
  ExpiresByType text/html "access plus 1 seconds"
  ExpiresByType image/x-icon "access plus 2592000 seconds"
  ExpiresByType image/gif "access plus 2592000 seconds"
  ExpiresByType image/jpeg "access plus 2592000 seconds"
  ExpiresByType image/png "access plus 2592000 seconds"
  ExpiresByType text/css "access plus 2592000 seconds"
  ExpiresByType text/javascript "access plus 2592000 seconds"
  ExpiresByType application/x-javascript "access plus 2592000 seconds"
  ExpiresByType application/x-shockwave-flash "access plus 2592000 seconds"
</IfModule>

But the answer remains the same Cache-Control: no-cache.
Uncommented in app.php: Now the response is Cache-Control: max-age=0. How to configure http cache for statics?
$kernel = new AppCache($kernel);

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Antonov, 2016-11-24
@antonowano

I already figured out that the set directives in .htaccess did not work. I worked with admins for a long time, until I got to the bottom of it and explained what headers the static should return - nothing worked out for us.
Caching worked at the level of reading headers and, according to the ETag and Last-Modified properties, decides whether to read the file further or not. I asked to add more Cache-Control or Expires, they indicate how long the cache can be used without sending a request to the server, even to read the header.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question