The Wayback Machine - https://web.archive.org/web/20241011092941/https://www.geeksforgeeks.org/what-is-a-manifest-file-in-html5/
Open In App

What is a manifest file in HTML5 ?

Last Updated : 27 Mar, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

HTML5 introduces a powerful feature known as the manifest file. Manifest is a text file that instructs the browser to cache specific files or webpages, enabling them to be used even when offline. The HTML5 cache webpages are specified using the manifest attribute in the <html> tag. All webpages containing manifest attributes or specified in the manifest file will be cached whenever a user visits that page.

Understanding the Manifest File

Manifest files are saved with the .appcache extension and always start with the CACHE MANIFEST keyword. They contain three sections: CACHE, NETWORK, and FALLBACK.

1. CACHE:

This section lists all the resources including webpages, CSS stylesheets, JavaScript files, and images that will be cached immediately after their first download. These resources can be used even in offline mode after their first download and don’t require a connection to the server.

Example: Create a file named cache.html and add it to the CACHE section of the demo.appcache file so as to cache it and use it in offline mode. This file will load in offline mode.

HTML
<!DOCTYPE html>
<html manifest="demo.appcache">
  
<body>
    <h1>Welcome to GeeksforGeeks!!</h1>
</body>
  
</html>

2. NETWORK:

This section lists all the resources that will never be cached. These resources can’t be used in offline mode and always require a connection to the server.

Example: Create a file named network.html and add it to the NETWORK section of the demo.appcache file so as to ensure that it is only available in online mode. This file will not load in offline mode.

HTML
<!DOCTYPE html>
<html>
   
<body>
    <h1>Welcome to GeeksforGeeks!!</h1>
    <p>Available only in online mode!</p>
</body>

</html>

3. FALLBACK:

This section lists the fallback resources that will be used in case a page is not accessible. It specifies the primary resource that will be replaced with the fallback resource specified next to it in case of server connection failure.

Example: Create a file named offline.html and add it to the FALLBACK section along with fallback.html in the demo.appcache file. In the offline mode, offline.html will be replaced with fallback.html. Following is the code for offline.html:

HTML
<!DOCTYPE html>
<html>

<body>
    <h1>Welcome to GeeksforGeeks!!</h1>
    <p>You are working in online mode.</p>
</body>

</html>

Following is the code for fallback.html:

HTML
<!DOCTYPE html>
<html>

<body>
    <h1>Welcome to GeeksforGeeks!!</h1>
    <p>You are working in offline mode.</p>
</body>

</html>

Following will be the content of the demo.appcache file:

CACHE MANIFEST

CACHE:
cache.html

NETWORK:
network.html

FALLBACK:
offline.html fallback.html

Now, create index.html to link all the above files.

HTML
<!DOCTYPE html>

<html manifest="demo.appcache">
  
<body>
    <h1>GeeksforGeeks</h1>
    <a href="cache.html">Cached File</a>
    <a href="network.html">Network File</a>
    <a href="offline.html">Fallback File</a>
</body>
</html>

Output:

Manifest file cached output in offline mode



Similar Reads

How to define the URL of an external script file in HTML5 ?
In this article, we will learn how to define the URL of an external script file inside HTML. This may be needed when a large script code is needed to be included, and it may create confusion if all the code is written in a single file. Also, there may be a requirement for the same script to execute on different web pages, and rewriting the same cod
1 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 URL of the media file in HTML5 ?
Here we will see how to set the URL of a media file using HTML. To set the URL of media file we use <source> tag. This tag is used to attach multimedia files like audio, video and pictures. The <audio>, <video> and <picture> elements contain the <source> element. Syntax: <source src="" type=""> // Statements <
1 min read
How to include JavaScript File in HTML5 ?
In HTML5, we can include external scripts using the <script> element. External scripts are commonly used to link JavaScript files or other script files hosted externally. Here's how you can include external scripts in HTML5. Link the External Script in HTMLTo link an external script in HTML, use the <script> tag with the src attribute p
1 min read
How to define the URL of the video file in HTML5?
In this article, we will learn how to define the URL of a video in HTML. The <video> tag is used to embed video files on a web page. This displays a video player along with the player controls depending on the browser. The source of the video can either be a singular one or it can be made to support multiple formats of the video so that multi
3 min read
Remove the Chrome's "No file chosen option" from a file input using JavaScript
The task is to remove the "no file chosen" value from the empty input element in chrome. We are going to achieve that task with the help of JavaScript. Approach 1: Remove the tooltip value('No file chosen'). Use .attr() method to set the value of title attribute to empty. Example 1: This example removes the tooltip value. <!DOCTYPE HTML> <
2 min read
How to reset selected file with input tag file type in Angular 9?
To reset the selected file with input tag file type, we can implement a method which on invocation will clear the selected file. Approach: Set the id of your input using '#' to make it readable inside the component.Now in the component we can use ViewChild directive to read the value of the input from the HTML view.For that, import ViewChild from @
2 min read
Convert JSON file into CSV file and displaying the data using Node.js
There are so many ways to store data for better understanding for individual purposes, in few cases, JSON files will be more suitable in few cases, CSV files, and there are also lots of other types as well like XML, etc. In this article, we will convert the JSON file data into CSV file data and also display that through Node.js. JSON stands for Jav
3 min read
How to include content of a PHP file into another PHP file ?
Including the content of a PHP file into another file reduces the complexity of code by reducing the code and improving its modularity by splitting the code into different files so that it is easy to understand and manage. There are two ways to do it by using the following PHP functions. PHP include() Function: It will show the warning if the file
2 min read
How to generate TypeScript definition file from any .js file?
A TypeScript definition file or a type declaration file is any TypeScript file that has the .d.ts filename extension. These files are only meant to hold the type declarations of that particular script and not the source code itself. This means that they are not a part of the compilation process. In this article, we will see how to generate a TypeSc
2 min read
Difference between AI File Format and EPS File Format
AI stands for Adobe Illustrator and this file format was built to control the file size of high graphic images. This file format also works on a Postscript base. It was designed by Adobe corporation to manage vector drawings or artwork in an easier and more efficient manner. It uses the .ai file extension to save Adobe illustrator files. EPS stands
2 min read
How to include a JavaScript file in another JavaScript file ?
In native JavaScript, before ES6 Modules 2015 was introduced had no import, include, or require functionalities. Before that, we can load a JavaScript file into another JavaScript file using a script tag inside the DOM that script will be downloaded and executed immediately. Now after the invention of ES6 modules, there are so many different approa
3 min read
How to delete file from the firebase using file url in node.js ?
To delete a file from the Firebase storage we need a reference to store the file in storage. As we only have the file URL we need to create a reference object of the file in Firebase storage and then delete that file. Deleting a file using the file URL can be done in two steps - Get the reference to the storage using the refFromUrl method from Fire
2 min read
How to Load an HTML File into Another File using jQuery?
Loading HTML files into other HTML files is a common practice in web development. It helps in reusing HTML components across different web pages. jQuery is a popular JavaScript library, that simplifies this process with its .load() method. Approach 1: Basic Loading with .load() MethodThe .load() method in jQuery is used to load data from the server
2 min read
How to display variable from .ts file to .html file in angular 17
In Angular, when you're working on a component, you use TypeScript files (.ts) to write the code that controls how the component behaves. On the other hand, HTML files (.html) handle how the user interface looks and gets displayed. Table of Content Data BindingSteps to Create Angular ApplicationInterpolationProperty BindingIf you want to show a var
3 min read
What is the Limit File Format when using <input type="file"> ?
In this article, we will learn how to limit file format when using HTML input tags. By using Hypertext markup language(HTML) language, we cannot restrict any users to choose any type of file from the browser (developed by the developer). But, we can apply some limitations by using <input type="file">. File formats can be limited or restricted
3 min read
How to convert a file to zip file and download it using Node.js ?
The Zip files are a common way of storing compressed files and folders. In this article, I'll demonstrate how to convert the file to zip format by using the adm-zip module (NPM PACKAGE). Uses of ADM-ZIP compress the original file and change them to zip format.update/delete the existing files(.zip format).Installation of ADM-ZIP: Step 1: Install the
3 min read
How to Link JavaScript File to a Separate HTML File?
To link a JavaScript file to a separate HTML file means to establish a connection between the HTML and JavaScript files. This is typically done using the `<script>` tag in the HTML file, specifying the source (src) attribute as the path to the JavaScript file, allowing execution of JavaScript code within the HTML document. Below are the appro
3 min read
How to import regular CSS file in SCSS file ?
Importing a regular CSS file into a SCSS file allows you to use standard CSS styles within your SCSS file. This is done by using the @import directive, enabling the CSS file to be included and compiled along with SCSS styles during preprocessing. @import keyword: The @import keyword in SCSS allows you to combine multiple SCSS and CSS files into one
3 min read
How to get file input by selected file name without path using jQuery ?
To get the selected file name without the path using jQuery, use the HTML <input type="file"> element. Upon file selection, the jQuery change() method captures the event, and the file name is retrieved using the name property of the event target's files. Syntax:$(selector).change(function(e){});Example 1: In this example we demonstrate how to
2 min read
How to set a name for keygen element in HTML5 ?
In HTML, the <keygen> tag is used to specify a key-pair generator field during a form, and the <keygen> name attribute is used to set the name of the keygen element. The aim of <keygen> element is to supply a secure thanks to authenticate users. When a form is submitted then two keys are generated, the private key and the public k
2 min read
How to change the font of HTML5 Canvas using a button in Angular.js?
In this article, we are going to learn about how to change the font of HTML5 Canvas using a button in AngularJS. With the help of a click font's property can change by the user whether it is font-size or font-style. Syntax: For font size (Change the font size accordingly): variable.fontSize = "100px" For font style (Change the font style accordingl
2 min read
How to define a client-side script in HTML5 ?
To define a client-side script in HTML5, we can do <script> tag or adding external script file by src attribute to the HTML file. <script> tag contains the JavaScript to be added for the client-side scripting. Syntax: <script> // JavaScript goes here console.log('GeeksforGeeks'); </script> Below are the examples for the abov
1 min read
HTML5 Game Development | Infinitely Scrolling Background
Game Design and Development is an emerging industry. Although making AAA titles will require advanced knowledge of game engines, DirectX, OpenGL, etc. small HTML5 video game projects is a good place to start. HTML5 canvas and javascript can be used to make small games while learning the fundamentals of game development like Collision-Detection, Obj
5 min read
HTML5 | Mathematical operators
Mathematical Operators are used for representation of mathematical and technical operators. In HTML5 some special codes are used. For the representation of these operators we can use the name or hexadecimal(Hex) reference. Examples: Input : &minus or &#8722 Output : - Input : &times or &#215 Output : x Input : &frac34 or &#1
1 min read
HTML5 MathML <menclose> Tag
The HTML5 MathML <menclose> tag tag is an inbuilt element in HTML5. It is used to renders the contents which is inside of anbenclosing notation specified by the notation attribute. Syntax: <menclose attribute="value "> child elements </menclose">Attributes: The tag accepts some attributes which are listed below: class| id| style:
2 min read
HTML5 MathML rowspan Attribute
This attribute holds the value that how many rows does the cell extend. This attribute is accepted by the <mtd> tag only. Syntax: <element rowspan="non-negative-int"> Attribute Values: non-negative-int: This value holds the integer that create the span by rows. Below example illustrate the rowspan in HTML MathML: Example: C/C++ Code
1 min read
HTML5 MathML rowlines Attribute
This attribute holds the row borders value that multiple value can be separated by using a space can consider also. Possible values are none, solid and dashed. This attribute is accepted by <mtable> tag only. Syntax: <element rowlines="none|solid|dashed"> Attribute Values: none: This attribute sets the row lines of the table none.solid:
1 min read
HTML5 date attribute in <input> Tag
The date attribute in the input tag creates a calendar to choose the date, which includes day, month, and year. Syntax: <input type = "date">Example 1: Use date attribute in input tag C/C++ Code <!DOCTYPE html> <html> <head> <title>Date Attribute</title> </head> <body> <form action="/"
1 min read
How to add video in HTML5 ?
In This article, we will define how to add video content using a <video> element in the document. Before HTML5 came into existence, videos could only be played in a browser using a plugin like flash, but after the release of HTML5, adding a video to a web page is easy as adding an image. The HTML5 “video” element specifies a standard way to e
1 min read