The Wayback Machine - https://web.archive.org/web/20241011092948/https://www.geeksforgeeks.org/what-is-the-application-cache-and-why-it-is-used-in-html5/
Open In App

What is the Application Cache and why it is used in HTML5 ?

Last Updated : 18 Aug, 2021
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The task is to learn about the application cache in HTML5. HTML stands for HyperText Markup Language and it is used to design web pages using a markup language. HTML5 is current or we can also say that it’s the 5th version of HTML.

Application Cache in HTML5: The current version of HTML5 introduces application cache, which means that a web application is cached, and accessible without an internet connection. Now we can make an offline web application that will run without an internet connection by just creating a manifest file in our application. 

Syntax:

<html manifest="demo.appcache">

Structure of HTML file: HTML is nothing but just an element tag that comes after the doctype tag in HTML structure. 

 

HTML




<!DOCTYPE html>
<html>
  <!-- In this element we will add an attribute
       called manifest attribute-->
  <head>
    <title>Page Title</title>
  </head>
  <body>
    <h2>Welcome To GFG</h2>
    <p>It is a paragraph element</p>
  
  </body>
</html>


Let us understand the concept of application cache with the help of an example.

Approach: 

  • Create an HTML file with the manifest attribute.
  • Create another HTML file then link it to the previously created HTML file.

Example: The name of the main file is “index.html”. First, the main file will execute and when you try to open the linked page the next page will run. After that, you just have to go offline and reload the page. the content of the page will still work fine.

HTML




<!DOCTYPE html>
<html manifest="demo.appcache">
  <body>
    Welcome to GeeksForGeeks.
    <p>
      Try opening <a href="index2.html">this page</a>,
      then go offline, and reload the page. The content 
      should still work.
    </p>
  
  </body>
</html>


HTML




<!DOCTYPE html>
<html manifest="demo.appcache">
  <body>
    Welcome to GFG, a computer science portal for geeks.
  </body>
</html>


Output: 

Uses of the application cache are:

  • Offline browsing: The users can use the application whenever they want to access the site when they’re offline
  • Speed: When the data is already stored then it is easy to access data with the greater speed, cached resources load faster than uncached resources.
  • Reduced server load: The browser will only download updated resources from the server.

Supported browsers:

  • Chrome 4.0 and above
  • Internet 10.0 and above
  • Mozilla Firefox 3.5 and above
  • Opera 11.5 and above
  • Safari 4.0


Similar Reads

Difference Between HTML5 Application Cache And Regular HTML Browser Cache ?
Most web applications like accessing a bank website, online shopping store, etc., all need a network connection. Due to several reasons, the network connectivity might be lost and hence users cannot able to understand what is happening, or at least they should get intimated as "server is offline, try after some time/few services like initial level
5 min read
npm cache clean - How to Clear the Cache in NPM ?
Clearing the cache in NPM (Node Package Manager) is very important. It helps to resolve various issues and ensures smooth functioning of the Node.js projects. The NPM cache stores downloaded packages and their metadata, which can sometimes become corrupted or outdated, leading to installation problems, dependency conflicts, or other issues. Table o
5 min read
Why Bootstrap is used for mobile application developments ?
Bootstrap is an open-source CSS framework that was developed by Mark Otto. It is mobile-friendly which means the templates render well on every device type. Bootstrap has all the basic templates available needed for basic website development. The framework has various forms, navbar, panels, jumbotron available which can be used for making beautiful
4 min read
How to Cache Ejs and Built the Progressive Web Application with Nodejs?
To cache EJS (Embedded JavaScript) templates and build a Progressive Web Application (PWA) with Node.js, we need to leverage several key technologies. Caching EJS templates can significantly enhance performance by reducing the need to recompile templates on each request. we'll learn how to cache EJS and build the Progressive Web Application with No
4 min read
How to specify the character encoding used in an external script file in HTML5 ?
To specify the character encoding used in an external script file in HTML5 we use <script> charset attribute. The charset attribute specifies the character encoding for the HTML document when used by the <meta> element. The charset attribute specifies the character encoding used in an external script file when used by the <script>
1 min read
How to specify the kind of marker to be used in the list in HTML5 ?
There are two types of lists in HTML, the first is an ordered list which is created using the <ol></ol> tag, and the second is an unordered list which is created using the <ul></ul> tag. Both of the lists should have a <li></li> tag to represent the data inside them. The ordered list represents the data in a coun
3 min read
How to specify URL of resource to be used by the object in HTML5 ?
In this article, we will cover how to specify the URL of the resource to be used by the object in HTML5. It can be used on pages where content from an external source is required. It can be done by setting the data attribute to the specified URL in the <object> tag. Syntax: <object data="URL"> Possible Values absolute URL: It points to
1 min read
What is the <picture> Element used for in HTML5 ?
The <picture> element in HTML5 is used for responsive image rendering. It allows developers to provide multiple sources of an image and define different versions based on factors like screen size or resolution. This also ensures optimal image display across various devices, promoting a more efficient and visually pleasing user experience with
1 min read
What is fallback in Application cache ?
In this article, we will discuss what is a fallback in the Application Cache! Fallback is a session in the Manifest file so before moving directly to the fallback, let's first see a brief description of the Application cache and Manifest file. Introduction: The Application Cache allows developers to make their web-browsers work online as well as of
5 min read
What is an ‘application cache’ ?
Web applications must be accessible without an internet connection. Almost all web-based applications work in online mode. So current version of HTML provides the functionality to work with the web-based application in online and offline modes.  HTML5 provides application cache functionality that allows a web application to run without the internet
3 min read
Why does SASS cache folder is created ?
CSS is used to style and design web pages and in general improve the User Interface and Experience of a web page. The Development of such CSS design templates involves making the resources for CSS and then writing the code after which testing is done. Testing involves compiling the program before executing it. This compilation of CSS resources and
2 min read
Why are HTTP cookies used by Node.js for sending and receiving HTTP cookies?
The HTTP protocol is one of the most important protocols of the Application layer of the OSI model. The main use of this protocol is for sending hypertext information to the client to the server and server to the client to communicate on the World Wide Web. But, the HTTP protocol is a stateless protocol which means that this protocol cannot maintai
5 min read
What are template engines in Express, and why are they used?
A Template Engine simplifies the use of static templates with minimal code. During runtime on the client side, variables in the template are replaced with actual values. These engines help developers create templates for web pages, written in a markup language with placeholders for dynamic content. When rendered, these placeholders are substituted
4 min read
What is TypeScript, and why is it used in Angular?
TypeScript is an open-source programming language developed and maintained by Microsoft. It is a superset of JavaScript that adds static typing to the language, enabling it to catch errors and improve code quality during development. TypeScript is widely used in Angular applications due to its scalability, maintainability, and tooling support benef
3 min read
How to define a container for an external (non-HTML) application using HTML5?
The approach of this article is to define a container for an external application by using a <embed> element in the Document. This is used for embedding external application which is generally multimedia content like audio or video . It is used as a container for embedding plug-ins such as flash animations. Syntax: <embed attributes> Ex
1 min read
Why <big> tag is not in HTML5 while <small> tag exists ?
The <big> tag was discontinued in HTML5 while <small> tag is still in handy because <small> tag is frequently used to represent small prints like footnotes, copyright notices, comments etc. Many alternatives for <big> tag are already available such as <h1>, <h2> and so on. In HTML5 instead of using <big>, y
2 min read
Why “chucknorris” is used as a color in HTML ?
The HTML accepts non hexadecimal character as 0 so we all know that 0-9 define zero to nine then A-F define ten to fifteen. So there are so many words that can be a color like chucknorris as deep blood red color like this. If you are putting any word at bgcolor that contains a few hexadecimal character then that character will show you some unexpec
2 min read
Why switch keyword used in React Router v4 ?
ReactJS is a javascript library that is used to build single-page applications (SPA). React by default does not provide the routing features. We can implement routing in ReactJS projects using React Router. React Router is a library that enables navigation among views of various components in a React Application, allows changing the browser URL, an
5 min read
Why Express is used in Web Development?
Express JS is a small web application framework. It become very popular Node JS framework for building robust and scalable application. In this article we will dive into the topic of ExpressJ S. Table of Content What is Express JS?Why Express is used in web development?Steps to create an Express applicationWhat is Express JS?Express is a small fram
3 min read
Why is HTML used in Web Pages ?
Web pages are built using the HyperText Markup Language or HTML. It is a markup language that defines a webpage's content and structure using tags. These tags provide instructions to web browsers on how to show links, photos, videos, text, and other content. Consider HTML as a house's plan, detailing the rooms, doors, windows, and general design. T
9 min read
Why Express Is Used For Enterprise App Development ?
While building a web application the most important thing is to decide which frameworks and libraries to use for the project that will support for long term and be able to handle all the requests efficiently. In this article, we will see why Express will be one of the best choices for you if you want to build an enterprise-level application. Table
6 min read
Why Zlib is used in Node.js ?
Zlib is a crucial library in Node.js used for data compression and decompression. It's widely employed in web development and various applications to handle data more efficiently. Understanding Zlib's significance in Node.js can greatly enhance your capability to manage data transmission, storage, and overall application performance. What is Zlib?Z
4 min read
How to convert angular 4 application to desktop application using electron ?
Using Electron JS, we can convert our existing angular project into a desktop application very easily. In this post, we will create a sample Angular project and convert it into a Desktop application step by step. Prerequisites: NPM Must be installed Environment Setup: Install Angular CLI:npm install -g @angular/cliCreate a new Angular Project. Here
3 min read
Why we use jQuery in our web application ?
jQuery is a fast, feature-rich, and lightweight JavaScript library. The main purpose of using jQuery is to make it much easier to use JavaScript on your modern and smart website. It is highly recommended to have a basic knowledge of HTML, CSS, and JavaScript. jQuery was developed to save the time of developers by reducing the code. It takes loads o
3 min read
Why to use code splitting in a React application?
Code splitting is a technique used in React applications to improve performance and user experience by splitting the application's bundle into smaller chunks that are loaded dynamically as needed. Reasons to use code splitting:Faster Initial Page Load: By splitting the application bundle into smaller chunks, only the necessary code for the initial
2 min read
How to Clear the NPM Cache on Linux, macOS, and Windows ?
Are you experiencing sluggishness or inconsistencies in your React or React Native projects? It could be due to caching issues within npm, the Node Package Manager. In this article, we'll explore why clearing the npm cache is important, how it impacts React and React Native development, and provide step-by-step instructions to clear the cache on Li
3 min read
HTTP headers | cache-control
The Cache-Control header is a general header, that specifies the caching policies of server responses as well as client requests. Basically, it gives information about the manner in which a particular resource is cached, location of the cached resource, and its maximum age attained before getting expired i.e. time to live. Syntax: Cache-Control:
3 min read
How to store single cache data in ReactJS ?
Storing Data in a cache is an important task in web applications. We can cache some data into the browser and use it in our application whenever needed. Caching is a technique that helps us to store a copy of a given resource in our browser and serve it back when requested. PrerequisitesReact JSCacheStorageApproachTo store single cache data in Reac
2 min read
How to Manage Service Worker Cache in JavaScript?
A service worker's ability to cache resources is crucial for a performant and reliable web application. By storing frequently accessed files like HTML, JavaScript, and images, you can enable offline functionality and faster loading times. Below are the approaches to manage service worker cache in JavaScript: Table of Content Caching Responses from
3 min read
How to Set an Expiration Date for Items in a Service Worker Cache using JavaScript?
Service workers empower web applications to cache resources for offline access and improved performance. However, outdated cached data can negatively impact user experience. This article explores two effective strategies for setting expiration dates for cached items within a service worker using JavaScript, ensuring your application delivers fresh
4 min read