17
location /static { alias /home/ubuntu/Documents/zibann/momsite/momsite/static; # your Django project's static files - amend as required if ($uri ~* ".*config.js") { expires off; } if ($uri ~* ".*\.(js|css|png|jpg|jpeg|gif|swf|svg)" ) { access_log off; expires 365d; add_header Cache-Control public; } } 

Hoping config.js would not get cached, but it does.
How can I exclude one file from being cached?

1
  • If you know the path of config.js, use a = location or a prefix location. Commented Apr 6, 2015 at 15:23

2 Answers 2

23

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

location ~ config\.js { alias xyz; expires off; } location static etc 
Sign up to request clarification or add additional context in comments.

Comments

0

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; } } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.