In the root web. config we specify that we don't want to the index. html to cache by setting the cache-control , Pragma and Expires request headers as well as the max-age to 0.
Cloudflare doesn't cache html by default.
My current project is almost working with the following configuration:
root %%COMP_WEB_ROOT;
# COMP Static File serving
location /comp {
alias %%COMP_WEB_ROOT;
try_files $uri$args $uri$args/ /index.html;
add_header 'Cache-Control' 'no-cache, no-store, must-revalidate';
}
# Hide the index file, not exposing that path specifically
location = /index.html {
internal;
}
With this, I am preventing caching for the entire application, which is not desirable, since I only want to prevent the index.html page from storing cache.
So I have tried to put the add_header
line inside the second block like this:
root %%COMP_WEB_ROOT;
# COMP Static File serving
location /comp {
alias %%COMP_WEB_ROOT;
try_files $uri$args $uri$args/ /index.html;
error_page 401 = @error401web;
}
# Hide the index file so that we're not exposing that path specifically
location = /index.html {
internal;
add_header 'Cache-Control' 'no-cache, no-store, must-revalidate';
}
NGINX is able to run, but index.html seems to still storing the cache as if the add_header
isn't there.
Is there some other command I am missing?
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