Home > Article > Backend Development > http Cache-control catalyst control center led control system amd catalyst control cente
Expires is the web server response message header field. When responding to an http request, it tells the browser that the browser can directly fetch data from the browser cache before the expiration time without requesting again.
Cache-Control has the same function as Expires. They both indicate the validity period of the current resource and control whether the browser directly fetches data from the browser cache or resends the request to the server to fetch data. It's just that Cache-Control has more choices and more detailed settings. If it is set at the same time, its priority is higher than Expires.
1. Common values of cache-control of Http protocol and their combined interpretations:
no-cache: The data content cannot be cached, and the server is revisited for each request. If there is max-age, the cache period No access to the server.
no-store: Not only cannot be cached, but also cannot be temporarily stored (ie: the resource cannot be temporarily stored in the temporary folder)
private (default): can only be cached in the browser, only in the first The server will only be accessed when the request is made. If there is max-age, the server will not be accessed during the cache period.
public: Can be cached by any cache area, such as: browsers, servers, proxy servers, etc.
max-age: relative expiration time, That is, the cache time in seconds.
no-cache, private: Re-access the server when opening a new window. If max-age is set, the server will not be accessed during the cache period.
private, positive max-age: No access when going back. Will access the server
no-cache, positive max-age: will access the server when going back
The instructions in the response message include public, private, no-cache, no-store, no-transform, must-revalidate, proxy-revalidate, and max-age.
3. nginx settings:
1) If expires is not configured in nginx, the response will default to Cache-Control: private
2) Set expires -1, then the response will be Cache- Control:no-cache
3) You can set add_header Cache-Control no-store in the response; then the response is: Cache-Control:private Cache-Control:no-store
location ~ ^/ { expires -1; #add_header Cache-Control no-store; proxy_pass http://api.yuedu.web; }
The above introduces http Cache-control, including control and cache aspects. I hope it will be helpful to friends who are interested in PHP tutorials.