1

I am trying to enable browser cache the javascript, css files of my web application. The document type I'm using is a JSP.

I see manifest.appcache is deprecated, what is the best way to implement caching so that browser caches the js, css files.

Below is my code

<html manifest="../manifest.appcache">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>Web app</title>
    <link rel="stylesheet" href="<%= contextPath %>/app.css">
</head>
<body>
    <script type="text/javascript" src="<%= contextPath %>/app.js"></script>
</body>
</html>

1 Answers1

0

You have to add Expires to your http response headers. This will make the browser in the client side to save the component of the page until that date. If you wonder how to set the headers while sending a response, you have to know to configure your server either by using a back-end programming language, or a third party.

Please see expires header .

Try adding this to your html file <meta http-equiv="Cache-control" content="public">

Ahmed Can Unbay
  • 2,694
  • 2
  • 16
  • 33