Prevent Index.html from being stored in cache

Currently, Index.html contains numerous JavaScript files that are concatenated and minified into a single file. This consolidated file undergoes a name change due to the filerev grunt task.

Although this process functions correctly, an issue arises when Index.html is cached, causing it to reference old JS file names after a new deployment. How can we ensure that Index.html always retrieves the latest version from the server? Alternatively, how can we implement regular checks every 15 minutes for updates?

Appreciate any guidance on this matter.

Answer №1

To handle these matters, typically they are controlled on the webserver. However, a quick solution involves inserting these meta tags in your header:

<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Determine the y-coordinate of terrain in Three.js

I have acquired a Collada model of terrain and now wish to incorporate other models onto this terrain. To achieve this, I believe I need to retrieve the height coordinate (y) of the terrain based on specific x and z coordinates. Can someone please guide ...

The variable req.body.username is not defined in the context of JavaScript

I am completely new to JS, Angular.js and node.js. I am currently working on a login-register project but facing a minor issue. Below is my code: login.ctrl.js: var app = angular.module('login-register', []); app.factory('UserLog', ...

What is the best way to send multiple PHP variables to an ajax function when clicked?

I'm encountering an issue while trying to pass variables to a function in my controller using AJAX. The error message at the bottom of the image is preventing the variables from being passed successfully. My setup involves the use of the CodeIgniter ...

Trouble in Angular JS: Syntax glitches

Here is the factory that I am working with: (function() { angular.module('temp') .factory('Factory',Factory); employeeFactory.$inject = ['$http']; function employeeFactory($http) { var factory = {}; ...

What could be the reason for the CORS failure when making requests from an HTTPS domain to an HTTP localhost

I have a secure rest service (implemented as an Azure Function), hosted on HTTPS, under domain A. My website is also running securely on HTTPS but on domain B. I've set the CORS to use a wildcard *. Using jQuery on my website, I send Ajax requests ...

Tips for creating a single event listener that applies to all buttons

Is there a way to efficiently add an event listener to multiple buttons and retrieve the value of each one based on the one that was clicked? For example: <button id='but1'> Button1 </button> <button id='but2'> Button ...

Executing a search and obtaining XML data from an external source

Currently, I am faced with the challenge of using Ajax to submit a query to an external database located at http://foreignserver:1234/database?query="SELECT FROM WHERE". The goal is to execute the query, generate an XML file, and have it returned to me. Th ...

"Enhancing user experience with JQuery and MVC4 through efficient multiple file uploads

Currently, I'm facing a challenge in uploading multiple files alongside regular form data. While I had successfully implemented this functionality in PHP before, I am now attempting to achieve the same in ASP.NET MVC4 using C#. Below is the HTML form ...

Tips for transferring a function between stateful and stateless components

Looking to transfer a function from a stateful component to a stateless component, here's a snippet of the code. Below is the stateless code. const ProductsGridItem = props => { const { result } = props; const source = result._source; return ( ...

Evaluating a string or object for compatibility

In my possession, I have a PHP array that has been encoded in JSON format: <script> var registeredEmails = <?php echo(json_encode($emails)); ?>; </script> To verify that this is functioning properly, I conduct the following test: conso ...

updating the observable array in rxjs after every iteration

I am facing an issue with updating the status of contracts in my UI. I have an Observable that contains an array of ContractDto, which is displayed in a table using an async pipe. The 'status' column for each contract initially shows 'not pr ...

How can you display directions while using the Google Maps app in a React Native application?

I need assistance with rendering directions between two points (current location and a passed location). Currently, I am using Linking to open the Google Maps App. However, when clicking the button passing the (latitude, longitude), I want the map to disp ...

The code coverage for the "rendering expectations" test in a particular component is insufficient

In order to test a specific component in my application, I am utilizing react-test-render. The test is intended to ensure that the component renders properly. Despite defining all the necessary properties for the component in the test file, the test cover ...

Does Ajax XMLHttpRequest trigger the execution of servlet doFilter?

I've implemented an AJAX call from a JSP page as shown below: <head> <script> function loadXMLDoc() { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, ...

Is it beneficial to establish a universal ng-app scope within an AngularJS application that functions as a multi-page app?

Just dipping my toes into AngularJS waters, and this question will surely prove that. We're in the midst of revamping an existing app to take advantage of AngularJS for CRUD operations and more. Rather than starting from scratch, we've decided a ...

What is the best way to switch out the characters 'a' and 'b' in a given string?

Let's say we have the following text. Lorem ipsum dolor sit amet The revised text should look like this: merol merol merol merol Is there a predefined function in JavaScript that can help us replace characters like this within a string? ...

Guide on utilizing two separate collections to store different types of data for an application's users

I am looking to create a database collection similar to {username : "jack", password : "pass"} for storing doctors' login information. I believe I can achieve this during signup by implementing the following code: var Doctor = mongoose.model("doctor" ...

Is it possible that the images are unable to load on the page

The frontend code successfully retrieves the image links sent by the backend but encounters issues displaying them. Despite confirming that the imgUrl data is successfully fetched without any hotlink protection problems, the images are still not appearing ...

What is the best way to retrieve a property with a period in the method name in JavaScript?

One dilemma I'm facing is trying to access the tree.removenode method through chartContext in Angular. It's been a challenge for me to understand how to achieve this. https://i.stack.imgur.com/yG7uB.png ...

Tips for maintaining values in Kendo MultiSelect after editing within a grid template

I am encountering an unusual issue with a grid that displays a comma-separated list of values and utilizes an array in a template editor for the grid. When I add a value to the multiselect, save in the editor, and then reopen the editor, only one of the mo ...