Configure nginx to clear the client cache

How to configure nginx to clear the client cache

Clear the client cache
Cache policy: no-store means caching is not allowed, no-cache means caching is not allowed, must-revalidate means revalidation is required, max-age=0 means the cache expiration time is 0; set the Pragma field in the response header , indicating that caching is not allowed;
expiration time: -1 means immediate expiration

  location /index.html {
        add_header Last-Modified $date_gmt; 
	    add_header Cache-Control no-store,no-cache,must-revalidate,max-age=0;   
	    add_header Pragma no-cache; 
        add_header Cache-Control no-cache,private;
         expires -1;
    }

Differences between Cache-Control and Pragma:
1. Cache-Control is only available in HTTP/1.1, and Pragma is only available in HTTP/1.0.
2. Cache-Control is an instruction to force caching , and Pragma is used to instruct Cache, but it does not force caching.
3. The Cache-Control command is more comprehensive, such as supporting more commands and more parameters, while Pragma only supports a no-cache parameter to cancel the cache .

Guess you like

Origin blog.csdn.net/var_deng/article/details/128902273