Nginx, turn off cache for a specific file Nginx, turn off cache for a specific file nginx nginx

Nginx, turn off cache for a specific file


Make a separate location block for config.js above the others.

location ~ config\.js {    alias xyz;    expires off;}location static etc


I tried all samples above, and in other pages. The only thing worked for me was this. My file was a PHP and a I had to create a complete copy of my last part of the configuration file. Maybe replacing location ~ config.js will work for you too.

location ~ player\.php {        set $no_cache 1;            fastcgi_index  index.php;            include        fastcgi_params;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;               if (-f $request_filename) {                # Only throw it at PHP-FPM if the file exists (prevents some PHP exploits)                fastcgi_pass   unix:/tmp/run/php7-fpm.sock;                #fastcgi_read_timeout 3600;            }         }