The Wayback Machine - https://web.archive.org/web/20241011092940/https://www.geeksforgeeks.org/difference-between-html5-application-cache-and-regular-html-browser-cache/
Open In App

Difference Between HTML5 Application Cache And Regular HTML Browser Cache ?

Last Updated : 28 Nov, 2022
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

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 of view are available but not transactions, etc.,”. These features are possible via the HTML5 Application Cache mechanism.

Application CacheThe application

Browser Cache

Application cache is helpful to get the cached resources and assets that are available in the manifest file. Even whole website content also would be got because of retrieving the cached contents. Browser cache is helpful to get only visited pages and their associated assets of a website.
Prefetching of HTML pages/CSSthe /images/js etc and even a whole web page content retrieval is possible It is impossible to get

Application Cache helps with Offline browsing, Speed (Instead of accessing the files from the network, they can be accessible from the cache, thus increase in retrieval fastly)

Resilience (even for few-second breakups)

Though we do offline browsing, only visited pages are possible to get but not many resources of the website

Let us see how we get cached resources by means of the Application Cache

1. Specify a manifest attribute to the HTML tag of a web page:

  • In order to enable application caching, we need to add a manifest attribute to the HTML page. 
  • It is automatically cached as  the HTML file contains a manifest attribute
  • Hence it is not mandatorily necessary to add to the manifest file (But it is  good also if we add it there)
  • The manifest attribute should be given as an absolute URL or relative path, For the absolute URL, it must be under the existing web application. 

Example:

<html manifest="cacheelements.manifest">
    ...
</html>
  • Extension of manifest file can be anything but should be given with correct mime-type:
<html manifest="<path of URL>/sample.mf">
      ...
</html>
  • A manifest file should have mime-type text/cache manifest. Either a  custom file type  or .htaccess configuration must be added

2. Add a cache manifest file:

  • It is nothing but a text file that contains what resources need to be cached. When the network is not available and the user goes offline, cached resources are helpful to view the user.
  • content-type of  text/cache-manifest has to be specified in the manifest file,
  • It can contain multiple resources like below:

#Always CACHE MANIFEST should be the first line

CACHE MANIFEST

#Files will be including local files and external links
#HTML files

#css files 

#image files

#js files

Example:

CACHE MANIFEST
index.html
css/stylesheet.css
images/logo.png
scripts/main.js
#external url js files

One important feature that we need to see is if the resources need to be accessed only online means, we need to specify as

3.  NETWORK:

Example:

NETWORK 
* #All files
# If we need to specify few files, then they need to be listed down as follows
#File 1
#File 2 etc.,

NOTE: Even if we specify all files with * indication, the files other than those mentioned in the CACHE MANIFEST are available only when there is a network connection. CACHE MANIFEST files can be accessible even offline as well.

One more important feature to provide an alternative file to access, we need to specify as

4. FALLBACK: The browser is hinted out to note the alternative file that need to be served when the application goes offline.

It has two URLs. The first one is the requested one and in case if there is no network connectivity or the resource is unavailable at the mentioned location, second one will be served as an alternative.unavailable.

Example:

FALLBACK
#If there is no network connection, 
#users can see offlineViewFile.html
/ /offlineViewFile.html 
#In few fractions of seconds, if there is no network 
#then below features can be enabled like below
#If sample.java is inaccessible then, 
#users will see  staticPage.html
/sample.java /staticPage.html

#If images/important.jpg is inaccessible then, 
#users will see images/offlineImage.jpg 
images/important.jpg/ images/offlineImage.jpg

Order of Cache, Network, and Fallback can vary but always the first line should be CACHE MANIFEST. Let us combine everything in a single file:

CACHE MANIFEST
index.html
css/stylesheet.css
images/logo.png
scripts/main.js
#external url js files

NETWORK 
* #All files
# If we need to specify few files, then they need to be listed down as follows
#File 1
#File 2 etc.,

FALLBACK
#If there is no network connection, users can see offlineViewFile.html
/ /offlineViewFile.html 
#In few fractions of seconds, if there is no network then below features can be enabled like below
#If sample.java is inaccessible then, users will see  staticPage.html
/sample.java /staticPage.html

#If images/important.jpg is inaccessible then, users will see images/offlineImage.jpg 
images/important.jpg/ images/offlineImage.jpg

# Additional resources to cache can be specified again like below
CACHE:
images/welcome.gif
css/important.css
js/eventInformation.js

#HTML files that references the manifest is automatically cached. 
#But still it is good to indicate that as well.

Conclusion: As a difference between application cache and regular browser cache, application cache is more advantageous as it helps to serve the website 

  • offline
  • speed of retrieval of the data is faster than accessing it from the cache instead of the network
  • Application manifest helps to cache the required files and using Fallback, always there will not be accidental unavailability of files. Instead, users will be noted with user-friendly error pages
  • Users get the view pages and they will get provided the option of saving the data once the network is back, saved data is synced with the original data

But a regular browser cache cannot able to do the above. It just helps to get the user to visit pages.



Similar Reads

What is the Application Cache and why it is used in HTML5 ?
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 applicat
2 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
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
Difference between HTML and HTML5
HTML stands for Hyper Text Markup Language. It is used to design web pages using a markup language. HTML is a combination of Hypertext and Markup language. Hypertext defines the link between the web pages. A markup language is used to define the text document within the tag which defines the structure of web pages. This language is used to annotate
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
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
Difference between Regular functions and Arrow functions
Regular functions and arrow functions are two common ways to define functions in JavaScript, each with distinct behaviors. Regular functions offer traditional syntax and this context handling, while arrow functions provide a concise syntax and lexical this binding, making them ideal for callbacks and simpler expressions. Table of Content Regular fu
6 min read
Differences between HTML specification and Browser’s Implementation
HTML determinations, for example, HTML5 characterize a bunch of decisions that a report should stick to be "legitimate" as per that particular. What's more, a particular gives guidelines on how a program should decipher and deliver such a document. A program is said to "support" a specification in the event that it handles legitimate records as per
3 min read
Difference between server sent events and Websockets in HTML5
WebSockets WebSockets is a complicated technology that permits real-time interactive bidirectional communication between the client browser and a server. This is accomplished by establishing a standard method for the server to transmit information to the client without first receiving an invitation from the client, then enabling messages to be tran
4 min read
Difference between <nav> and <menu> tag in HTML5
"<nav>" Tag: The <nav> tag is used to specify navigation links either within the same document or any other document which means it provides link to contents which are either on same or different page/document. Example: <!DOCTYPE html> <html> <body> <h1>The nav element</h1> <p>The nav element defines
3 min read
Difference between XHTML and HTML5
XHTML is an older, stricter version of HTML that follows XML rules. HTML5 is the latest and more flexible version, bringing in new features for better multimedia and web applications. HTML5 is simpler to use, while XHTML demands strict adherence to XML standards. Table of Content XHTMLHTML5Similarities in the XHTML and HTML5Difference between HTML
4 min read
Explain the difference between head Tag and header Tag in HTML5 ?
The <head> element is a container for metadata and is placed between the <html> and <body> tags. The <header> is for the main content section's introductory elements, like headings or logos and it mainly focuses on what appears at the top of the webpage. <head> ElementThe <head> element is part of the HTML docume
1 min read
Difference between Web Browser and Web Server
For International Network communication, we require a web browser and web servers. Web browsers and servers play an important role in establishing the connection. The client sends requests for web documents or services. The message that goes from the web browser to the web server is known as an HTTP request. When the web server receives the request
3 min read
Difference between Website and Web Browser
Website : Website, as the name suggests, is basically a set of interconnected webpages that contain text, images, video, etc. and share a unique domain name. Its primary goal is to increase sales, products, etc., that in turn increase the growth of business. Web Browser : Web Browser, as the name suggests, is basically a software application that c
2 min read
Difference between Web Browser and Web Page
1. Web Browser :Web browser, as name suggest, is basically a software application that runs on computer and responds to request made by other computers on network. It also loads website much faster and use the latest WWW standards for displaying websites.Example : Firefox, Netscape, Safari, Explorer, etc.2. Web Page : Web Page, as name suggests, is
2 min read
Difference between Search Engine and Web Browser
Search Engine: A search engine is a kind of website through which users can search the content available on the Internet. For this purpose, users enter the desired keywords into the search field. Then the search engine looks through its index for relevant web pages and displays them in the form of a list. The Internet is a huge source of informatio
4 min read
Difference Between Audio & AudioContext in HTML5
Audio is an HTML5 element used to embed sound content in documents. It's a simple way to add audio to a webpage, but it lacks advanced features like real-time processing and effects. AudioContext, on the other hand, is a powerful API that provides more control over audio playback, including real-time processing, effects, and more. It's suitable for
3 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
How to validate HTML tag using Regular Expression
Given string str, the task is to check whether it is a valid HTML tag or not by using Regular Expression.The valid HTML tag must satisfy the following conditions: It should start with an opening tag (<).It should be followed by a double quotes string or single quotes string.It should not allow one double quotes string, one single quotes string o
6 min read
How to set a regular expression for an input element value that checked against using HTML ?
In this article, we will use <input> pattern attribute to set the regular expression pattern for an input field that checked against. The HTML <input> pattern attribute is used to specify the regular expression on which the input elements value is checked against. This attribute works with the following input types: text, password, date
1 min read
What can be done with style sheets that can not be accomplished with regular HTML ?
A Style Sheet is a file that contains a piece of code that is used to give styling to our web page. It is used to change various properties of a page like a page size, margins, fonts, font-size, etc. which is not possible by using just Regular HTML. In Web Development, Designing and structuring of web pages are done using HTML (defining the content
5 min read
How to define metadata about an HTML document in HTML5 ?
The metadata means the information about data. The <meta> tag in HTML provides information about HTML Document or in simple words, it provides important information about a document. These tags are basically used to add name/value pairs to describe properties of HTML documents, such as expiry date, author name, list of keywords, document auth
1 min read
How to specify the HTML content of the page to show in the iframe element HTML5 ?
In this article, we will learn how to specify the content of a webpage to <iframe> in a web browser statically and dynamically by using JavaScript with HTML. We need a web browser i.e., Chrome (recommended) or Electron Application. This article will explain the proper way to assign or embed any external webpage to another webpage or even chan
2 min read
How to define an HTML heading in HTML5 ?
An HTML heading tag is used to define the headings of a page. Headings are defined with the <h1> to <h6> tags. The size of the text depends upon the type of heading tag. h1 is the largest heading tag and h6 is the smallest one (h1 > h2 > h3 > h4 > h5 > h6). Syntax: <h1></h1> <h2></h2> <h6>
1 min read
What are the HTML tags that deprecated in HTML5 ?
In this article, we will see the various deprecated Html tags & their alternative tags in HTML5. Deprecated tags are those tags that are allowed, but not recommended for use and are being replaced by newer ones. The tag or attributes depreciated when the same attributes are achieved in some other way. Several reasons for being discarded & u
3 min read
How to specify the relationship between the current document and the target URL in HTML5 ?
We specify the relationship between the current document and the target URL by using a <link> tag in HTML. A link tag is used to define a link between a document and an external resource. It is used only when the href attribute is present. Approach: To specify the relationship between the current and the linked document use the rel attribute
2 min read
How to detect HTML 5 is supported or not in the browser ?
HTML 5 is the latest standard of HTML that includes many new changes and features. HTML 5 support can be detected by using three approaches:Method 1: Checking for Geolocation support: The Geolocation API was added in HTML5. It is used for identifying the user's location. The presence of this API could be detected by checking if the geolocation prop
4 min read
How to change browser theme-color using HTML ?
In this article, we will know how to change the browser theme-color in HTML. Suppose that if we want our website to appear in green color along with changing the browser theme color which will be the same as our website, then we can use a meta tag with name and content attribute. Meta Tag: The <meta> tag is used in the <head> element of
2 min read
Which media format is supported by the browser in HTML ?
HTML supports various media elements such as audio or video. It uses media tags such as <audio>, <video>, <source>, <embed> and <track> to include media files in HTML documents. Multimedia files can be in different formats (example- MP3, MP4, WEBM) which can be identified by looking at the extension of these files. Amo
6 min read