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?
Cache both static and dynamic content from your proxied web and application servers, to speed delivery to clients and reduce the load on the servers.
Nginx caches the responses in the disk, proxy_cache_path specifies the path where the responses are to be stored. proxy_cache defines the shared memory zone used for storing the cache keys and other metadata. proxy_cache_key defines the caching key.
NGINX and NGINX Plus utilize a hybrid disk‑and‑memory cache. Whether the cache is on disk, in SSD, or elsewhere, the operating system page cache brings a cached item into main memory when it's requested. The cached content that was requested least recently is swapped out when memory is required for other purposes.
Make a separate location block for config.js above the others.
location ~ config\.js {
alias xyz;
expires off;
}
location static etc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With