search
HomeWeb Front-endHTML TutorialWebkit's Research on Application Cache Implementation of HTML 5_html/css_WEB-ITnose

Due to work, I have been studying ApplicationCache for a while. First, let’s introduce some basic concepts of SQL DB Table related to it,

  • CacheGroups: It is a set of resources, such as html, css, js, image, they are related to a cache manifest Association, each cache item contained in the CacheGroups table has its own ID and corresponding manifest URL.
  • CacheEntries, CacheResources: These two tables store some resource metadata (metadta), such as HTTP header, mime type, etc.
  • CacheResourcesData: This table stores each resource in BLOB format.
  • Caches : This table stores the size of each resource.
  • In the Webkit/Source/WebCore/Loader/AppCache/ directory, there is its implementation: ApplicationCacheStorageXXX. When we compile Webkit, turn on the Offline Cache option, it will enable the HTML5 App Cache function and generate a SQL DB file named ApplicationCache.db in the cache directory specified by the user, so that when we put the manifest file on the Web side, it will be used To describe which files need to be cached, and when those files do not need to be cached, Webkit's Loader will decide whether to store the resource in this file based on the manifest description, and whether to load resources such as images from this DB, so as to avoid requests from the Network. , which can greatly save costs.


    For more introduction, please refer to the article from w3school.com.cn:

    Using HTML5, through Create a cache manifest file to easily create an offline version of your web application.

    What is Application Cache?

    HTML5 introduces application caching, which means web applications can be cached and accessed without an Internet connection.

    Application caching brings three benefits to apps:

  • Offline browsing - users can use apps while they are offline
  • Speed ​​- cached resources load faster
  • Reduce server load - the browser will only download updated or changed resources from the server.
  • Browser Support

    Application caching is supported by all major browsers except Internet Explorer.

    HTML5 Cache Manifest Example

    The following example shows an HTML document with cache manifest (for offline browsing):

    Example

    The content of the document......

    Try it yourself

    Cache Manifest Basics

    To enable application caching, include the manifest in the document's tag Attributes:

    ...

    Each page with a specified manifest will be cached when the user accesses it. If the manifest attribute is not specified, the page will not be cached (unless it is specified directly in the manifest file).

    The recommended file extension for manifest files is: ".appcache".

    Please note that the manifest file needs to be configured with the correct MIME-type, i.e. "text/cache-manifest". Must be configured on the web server.

    Manifest file

    Manifest files are simple text files that tell the browser what is cached (and what is not cached).

    The manifest file can be divided into three parts:

  • CACHE MANIFEST - files listed under this heading will be cached after the first download
  • NETWORK - under this heading Outgoing files require a connection to the server and will not be cached
  • FALLBACK - The files listed under this heading specify the fallback page when the page is inaccessible (such as a 404 page)
  • CACHE MANIFEST

    The first line, CACHE MANIFEST, is required:

    CACHE MANIFEST/theme.css/logo.gif/main.js

    The manifest file above lists three resources: a CSS file, a GIF image, and a JavaScript document. When the manifest file loads, the browser downloads these three files from the root directory of the website. Then, whenever the user disconnects from the Internet, these resources are still available.

    NETWORK

    The following NETWORK section specifies that the file "login.asp" will never be cached and is not available offline:

    NETWORK:login.asp

    You can use Star number to indicate that all other resources/files require an Internet connection:

    NETWORK:*

    FALLBACK

    The FALLBACK subsection below specifies that if an Internet connection cannot be established, "offline.html" is used instead of /html5 / All files in the directory:

    FALLBACK:/html5/ /404.html

    Note: The first URI is the resource, the second is the fallback.

    Update cache

    Once an app is cached, it remains cached until:

  • 用户清空浏览器缓存
  • manifest 文件被修改(参阅下面的提示)
  • 由程序来更新应用缓存
  • 实例 - 完整的 Manifest 文件

    CACHE MANIFEST# 2012-02-21 v1.0.0/theme.css/logo.gif/main.jsNETWORK:login.aspFALLBACK:/html5/ /404.html

    重要的提示:以 "#" 开头的是注释行,但也可满足其他用途。应用的缓存会在其 manifest 文件更改时被更新。如果您编辑了一幅图片,或者修改了一个 JavaScript 函数,这些改变都不会被重新缓存。更新注释行中的日期和版本号是一种使浏览器重新缓存文件的办法。

    关于应用程序缓存的注释

    请留心缓存的内容。

    一旦文件被缓存,则浏览器会继续展示已缓存的版本,即使您修改了服务器上的文件。为了确保浏览器更新缓存,您需要更新 manifest 文件。

    注释:浏览器对缓存数据的容量限制可能不太一样(某些浏览器设置的限制是每个站点 5MB)。


    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
    HTML: Is It a Programming Language or Something Else?HTML: Is It a Programming Language or Something Else?Apr 15, 2025 am 12:13 AM

    HTMLisnotaprogramminglanguage;itisamarkuplanguage.1)HTMLstructuresandformatswebcontentusingtags.2)ItworkswithCSSforstylingandJavaScriptforinteractivity,enhancingwebdevelopment.

    HTML: Building the Structure of Web PagesHTML: Building the Structure of Web PagesApr 14, 2025 am 12:14 AM

    HTML is the cornerstone of building web page structure. 1. HTML defines the content structure and semantics, and uses, etc. tags. 2. Provide semantic markers, such as, etc., to improve SEO effect. 3. To realize user interaction through tags, pay attention to form verification. 4. Use advanced elements such as, combined with JavaScript to achieve dynamic effects. 5. Common errors include unclosed labels and unquoted attribute values, and verification tools are required. 6. Optimization strategies include reducing HTTP requests, compressing HTML, using semantic tags, etc.

    From Text to Websites: The Power of HTMLFrom Text to Websites: The Power of HTMLApr 13, 2025 am 12:07 AM

    HTML is a language used to build web pages, defining web page structure and content through tags and attributes. 1) HTML organizes document structure through tags, such as,. 2) The browser parses HTML to build the DOM and renders the web page. 3) New features of HTML5, such as, enhance multimedia functions. 4) Common errors include unclosed labels and unquoted attribute values. 5) Optimization suggestions include using semantic tags and reducing file size.

    Understanding HTML, CSS, and JavaScript: A Beginner's GuideUnderstanding HTML, CSS, and JavaScript: A Beginner's GuideApr 12, 2025 am 12:02 AM

    WebdevelopmentreliesonHTML,CSS,andJavaScript:1)HTMLstructurescontent,2)CSSstylesit,and3)JavaScriptaddsinteractivity,formingthebasisofmodernwebexperiences.

    The Role of HTML: Structuring Web ContentThe Role of HTML: Structuring Web ContentApr 11, 2025 am 12:12 AM

    The role of HTML is to define the structure and content of a web page through tags and attributes. 1. HTML organizes content through tags such as , making it easy to read and understand. 2. Use semantic tags such as, etc. to enhance accessibility and SEO. 3. Optimizing HTML code can improve web page loading speed and user experience.

    HTML and Code: A Closer Look at the TerminologyHTML and Code: A Closer Look at the TerminologyApr 10, 2025 am 09:28 AM

    HTMLisaspecifictypeofcodefocusedonstructuringwebcontent,while"code"broadlyincludeslanguageslikeJavaScriptandPythonforfunctionality.1)HTMLdefineswebpagestructureusingtags.2)"Code"encompassesawiderrangeoflanguagesforlogicandinteract

    HTML, CSS, and JavaScript: Essential Tools for Web DevelopersHTML, CSS, and JavaScript: Essential Tools for Web DevelopersApr 09, 2025 am 12:12 AM

    HTML, CSS and JavaScript are the three pillars of web development. 1. HTML defines the web page structure and uses tags such as, etc. 2. CSS controls the web page style, using selectors and attributes such as color, font-size, etc. 3. JavaScript realizes dynamic effects and interaction, through event monitoring and DOM operations.

    The Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesThe Roles of HTML, CSS, and JavaScript: Core ResponsibilitiesApr 08, 2025 pm 07:05 PM

    HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

    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

    AI Hentai Generator

    AI Hentai Generator

    Generate AI Hentai for free.

    Hot Article

    R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. Best Graphic Settings
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    R.E.P.O. How to Fix Audio if You Can't Hear Anyone
    4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
    WWE 2K25: How To Unlock Everything In MyRise
    1 months agoBy尊渡假赌尊渡假赌尊渡假赌

    Hot Tools

    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.

    Atom editor mac version download

    Atom editor mac version download

    The most popular open source editor

    DVWA

    DVWA

    Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

    mPDF

    mPDF

    mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

    SAP NetWeaver Server Adapter for Eclipse

    SAP NetWeaver Server Adapter for Eclipse

    Integrate Eclipse with SAP NetWeaver application server.