G
G
grabbee2020-08-26 13:18:26
symfony
grabbee, 2020-08-26 13:18:26

What is the correct way to use NGINX cache along with SYMFONY?

Now I use api-platform - there you can set your own MAX-AGE headers for each resource (uri). And globally for all resources to install some.

I still do not understand how NGINX will work with this - will it take into account these headers or ignore it?

If I write fastcgi_cache_valid 30s; in

location ~ ^/index\.php(/|$) {
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_split_path_info ^(.+\.php)(/.*)$;
        include fastcgi_params;
          fastcgi_cache_lock on;
          fastcgi_cache phpcache;
          fastcgi_cache_valid 30s;


It seems that all requests will be cached the same way.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sl0, 2020-08-26
@grabbee

I didn’t quite understand what symfony has to do with it, nothing depends on it in this case.
According to the documentation:
If there is no "X-Accel-Expires" field in the header, caching parameters are determined by the "Expires" or "Cache-Control" header fields.
A response that has a "Set-Cookie" field in its header will not be cached.
A response that has a "Vary" field in the header with the special value "*" will not be cached (1.7.7). A response that has a "Vary" field in its header with a different value will be cached against the corresponding request header fields (1.7.7).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question