How to overwrite the cache-control header on Nginx?
-
Edit the main Nginx configuration file, usually /etc/nginx.conf, and enter these rules immediately after opening the http block:
map $upstream_http_x_wp_cf_super_cache_active $wp_cf_super_cache_active {
default ‘no-cache, no-store, max-age=0’;
‘1’ ‘s-max-age=604800, s-maxage=604800, max-age=60’;
}Now open the configuration file of your domain and add the following rules inside the block that deals with the management of PHP pages:
more_clear_headers ‘Pragma’;
more_clear_headers ‘Expires’;
more_clear_headers ‘Cache-Control’;
add_header Cache-Control $wp_cf_super_cache_active;Save and restart Nginx.
Thanks for your amazing cloudflare plugin and right now the site speed boost up dratically. However, I check there are two settings that require a mannually implement, for this cache-control header, I know how to do with the first paragraph, that I successfully entered into the nginx.conf file, but the second paragraph, I don’t know where should I add in.
Thank you for your help.
- The topic ‘How to overwrite the cache-control header on Nginx?’ is closed to new replies.