James
James

Reputation: 1456

Angular js browser issues

i'm working in angular js project, when i change any line of code in a js file i should go back to the browser and clear the cache and the navigation data. i'm wondering if there is a solution to force the browser to take my js changes without clearing the cache every time?

Thanks in advance.

Upvotes: 0

Views: 160

Answers (3)

Stephane Janicaud
Stephane Janicaud

Reputation: 3627

You can add those meta tags in your page

<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="CACHE-CONTROL" content="NO-CACHE">

You can also achieve this on server-side, assuming res is your response object

res.header('Cache-Control', 'private, no-cache, no-store, must-revalidate');
res.header('Expires', '-1');
res.header('Pragma', 'no-cache');

Checkout this article from Google to learn more about HTTP Caching

Upvotes: 3

Lukas Kolletzki
Lukas Kolletzki

Reputation: 2246

For your development process, you might use an extension like Cache Killer as suggested by @element11.

In production, you can use the HTML5 Application Cache to specify the files that should get cached. If you include a version comment in the cache manifest file, you can update this version comment with each release, and the clients will refresh their cache.

Additionally, you might want to take a look at service workers.

Upvotes: 0

Stephane Janicaud
Stephane Janicaud

Reputation: 3627

A very simple way to achieve this is to open Chrome Development Tools and check Disable cache option under Network tab.

Upvotes: 1

Related Questions