sp00k
sp00k

Reputation: 80

What is the best way to update an angular application?

Our team is constantly working on an angular application, and every week or 2 we update it with new features or correct some bugs that came out.

We are using a C# backend with webservices.

QUESTION: When we update the application on the server, we sometimes (this doesn't happen all the time) get the problem that user is still seeing the old HTML and functionalities. What is the way to solve this?

I didn't find this on google, maybe I'm not looking for the right terms, any help is appreciated.

Users have to clear their cache to get the new version of the application.

Upvotes: 1

Views: 113

Answers (2)

Michele Ricciardi
Michele Ricciardi

Reputation: 2117

What you are seeing are cached copies of the JS files (possibly HTML partials too).

When the browser parses the HTML page, it makes the request for getting the JS resource and looks at various information before deciding to retrieve either the cached copy (if any) or whether to query the server again.

You can find some extra details on the Google fundamentals on HTTP caching

A solution I have been adopting myself is to set the cache headers to cache the file for a very long period, and then use tools in the build to version the file either on the filename or with a request parameter.

I have used grunt-cache-breaker and found it to serve well for this purpose. I know there is a gulp equivalent too

Upvotes: 1

Hartger
Hartger

Reputation: 319

The most common way to make sure cached versions of your javascript aren't used is adding the version as a parameter in the reference to the script like so:

<script src="/app.js?v=v1.0"></script>

Upvotes: 1

Related Questions