Home > Web Front-end > JS Tutorial > A brief introduction to HTTP caching mechanism

A brief introduction to HTTP caching mechanism

不言
Release: 2019-03-21 11:09:18
forward
2446 people have browsed it

This article brings you a brief introduction to the HTTP caching mechanism. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

HTTP caching mechanism

HTTP caching is divided into two types: forced caching and comparative caching

Before we understand these, let’s briefly understand the HTTP message. The HTTP message is the browser and The data sent and responded to during server communication is fast.

Request header header Additional information (cookie, cache information, etc.) and cache-related rule information are included in the header

And the request body body The part that the HTTP request really wants to transmit

After briefly understanding these, let’s take a look at strong cache and contrast cache

Strong cache keyword expires cache-control max-age = set the expiration time and compare the last-modified record in the cache keyword response header Last request time
request header if-modified-since is compared with the last request time.
etag records the unique identifier if-none-match compares with etag to see if it is consistent and returns to the server to return the unique identifier
You can get the cached data status code 304

How to set up the request cache

The front-end sets http cache and the front-end sets html page cache method: If you want to set up cache for static html pages, you need to set expires and cache-control through HTTP META

Set the following web page meta information:

<meta http-equiv="Cache-Control" content="max-age=7200" />
 <meta http-equiv="Expires" content="Mon, 20 Jul 2013 23:00:00 GMT" />
Copy after login

This article is all over here. For more exciting content, you can pay attention to the JavaScript Tutorial Video column on the PHP Chinese website!

The above is the detailed content of A brief introduction to HTTP caching mechanism. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:segmentfault.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template