search
HomeWeb Front-endHTML TutorialThe role of meta in html pages and the analysis of page caching and non-caching settings

This article mainly introduces the caching and non-caching settings of the page and the relevant information about the role of meta in the HTML page. Friends in need can refer to the following

HTML's HTTP protocol header information controls the page's Cache information in several places, including the browser side, the intermediate cache server side (such as Squid, etc.), and the Web server side. This article discusses the caching situation of HTML pages with cache control information in the header information (HTML pages generated by JSP/Servlet) in the intermediate cache server.

The cache header keywords in the HTTP protocol include Cache-Control (HTTP1.1), Pragma (HTTP1.0), last-Modified, Expires, etc.

In HTTP1.0, page caching is controlled through Pragma , which can be set to: Pragma or no-cache. There are many articles on the Internet explaining how to control not allowing browsers or intermediate cache servers to cache pages. The value is usually set to no-cache, but this value is not so safe. Expires is usually set to 0 to achieve the purpose. But if we deliberately need the browser or cache server to cache our page, this value must be set to Pragma.

Enable Cache-Control in HTTP1.1 to control whether the page is cached or not. Here are some commonly used parameters:

•no -cache, neither the browser nor the cache server should cache page information;

•public, both the browser and the cache server can cache page information;

•no-store, request and response No information should be stored in the other party's disk system;

•must-revalidate, for each request from the client, the proxy server must verify with the server whether the cache is out of date;

Last- Modified is only the last generation time of the page, in GMT format;

Expires expiration date value, in GMT format, which means that the browser or cache server must obtain new page information from the real server after this point in time;

The above two values ​​will not take effect if they are set to character GMT format in JSP. They will only take effect if they are set to long type;

The following is a test example:

package com.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ServletA extends HttpServlet {
@Override
public void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
//servlet页面默认是不缓存的
//本页面允许在浏览器端或缓存服务器中缓存,时限为秒。
//秒之内重新进入该页面的话不会进入该servlet的
java.util.Date date = new java.util.Date(); 
response.setDateHeader("Last-Modified",date.getTime()); //Last-Modified:页面的最后生成时间 
response.setDateHeader("Expires",date.getTime()+); //Expires:过时期限值 
response.setHeader("Cache-Control", "public"); //Cache-Control来控制页面的缓存与否,public:浏览器和缓存服务器都可以缓存页面信息;
response.setHeader("Pragma", "Pragma"); //Pragma:设置页面是否缓存,为Pragma则缓存,no-cache则不缓存
//不允许浏览器端或缓存服务器缓存当前页面信息。
/*response.setHeader( "Pragma", "no-cache" ); 
response.setDateHeader("Expires", ); 
response.addHeader( "Cache-Control", "no-cache" );//浏览器和缓存服务器都不应该缓存页面信息
response.addHeader( "Cache-Control", "no-store" );//请求和响应的信息都不应该被存储在对方的磁盘系统中; 
response.addHeader( "Cache-Control", "must-revalidate" );*///于客户机的每次请求,代理服务器必须想服务器验证缓存是否过时;
System.out.println("进入了servlet");
response.getWriter().write("欢迎光临我的主页");
}
}

If necessary To set no caching on the html page, add the following statement to the

tag:
<meta>
<meta>
<meta>

Attachment: The role of meta in the html page

Meta is used to simulate the response header message of the HTTP protocol in HTML documents. The meta tag is used in the

and of the web page. The meta tag has many uses. There are two attributes of meta: name and http-equiv. The name attribute is mainly used to describe web pages, corresponding to content (web page content), so that search engine robots can find and classify them (at present, almost all search engines use online robots to automatically find meta values ​​to classify web pages). The most important of these are description (description of the site on search engines) and keywords (categorization keywords), so a meta value should be added to each page. The more commonly used ones are as follows:

 name attribute

 1. is used to describe the generation tool ( Such as Microsoft FrontPage 4.0), etc.;

 2. Indicate the keywords of your web page to the search engine;

 3. Tell search engines the main content of your site;

4. Tell search engines The author of your site;

 5.

  The attributes are described as follows:

Set to all: the files will be retrieved, and the links on the page can be queried;

Set to none: the files will not be retrieved , and the links on the page cannot be queried;

Set to index: the file will be retrieved;

Set to follow: the links on the page can be queried;

Set to noindex: the file will not be retrieved, but the links on the page can be queried;

Set to nofollow: the file will not be retrieved, but the links on the page can be queried.

 http-equiv attribute

 1. and Used to describe the text and language used to create the homepage;

Another example is that English is the ISO-8859-1 character set, as well as BIG5, utf-8, shift-Jis, Euc, and Koi8 -2 and other character sets;

2. Timingly allows the web page to jump within the specified time n Go to the page http://yourlink;

 3. can be used to set the web page The expiration time, once expired, must be called again on the server. It should be noted that the GMT time format must be used;

 4. is used to set the browser to prevent the browser from accessing the page content from the cache of the local machine. After setting, once you leave the web page, it cannot be retrieved from the cache;

 5. cookie setting, if the web page expires, the saved cookie will be deleted. It should be noted that the GMT time format must be used;

 6. Web page rating, there is a content setting in IE's internet options that can prevent browsing of some restricted websites, and the website The restriction level is set through the meta attribute;

7. Force the page to be displayed as an independent page in the current window, you can Prevent your own web page from being called as a frame page by others;

8. and Set special effects when entering and leaving the page. This function is the "format/web page transition" in FrontPage ", but the added page cannot be a frame page.

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

The difference in usage of href and onclick in the a tag of Html and the priority level

Use Requirejs in Html for modules Analysis of chemical development

The above is the detailed content of The role of meta in html pages and the analysis of page caching and non-caching settings. For more information, please follow other related articles on the PHP Chinese website!

Statement
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
The Future of HTML: Evolution and TrendsThe Future of HTML: Evolution and TrendsMay 13, 2025 am 12:01 AM

The future of HTML will develop in a more semantic, functional and modular direction. 1) Semanticization will make the tag describe the content more clearly, improving SEO and barrier-free access. 2) Functionalization will introduce new elements and attributes to meet user needs. 3) Modularity will support component development and improve code reusability.

Why are HTML attributes important for web development?Why are HTML attributes important for web development?May 12, 2025 am 12:01 AM

HTMLattributesarecrucialinwebdevelopmentforcontrollingbehavior,appearance,andfunctionality.Theyenhanceinteractivity,accessibility,andSEO.Forexample,thesrcattributeintagsimpactsSEO,whileonclickintagsaddsinteractivity.Touseattributeseffectively:1)Usese

What is the purpose of the alt attribute? Why is it important?What is the purpose of the alt attribute? Why is it important?May 11, 2025 am 12:01 AM

The alt attribute is an important part of the tag in HTML and is used to provide alternative text for images. 1. When the image cannot be loaded, the text in the alt attribute will be displayed to improve the user experience. 2. Screen readers use the alt attribute to help visually impaired users understand the content of the picture. 3. Search engines index text in the alt attribute to improve the SEO ranking of web pages.

HTML, CSS, and JavaScript: Examples and Practical ApplicationsHTML, CSS, and JavaScript: Examples and Practical ApplicationsMay 09, 2025 am 12:01 AM

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

How do you set the lang attribute on the  tag? Why is this important?How do you set the lang attribute on the tag? Why is this important?May 08, 2025 am 12:03 AM

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

What is the purpose of HTML attributes?What is the purpose of HTML attributes?May 07, 2025 am 12:01 AM

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

How do you create a list in HTML?How do you create a list in HTML?May 06, 2025 am 12:01 AM

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use