简体   繁体   中英

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.

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

实现此目的的一种非常简单的方法是打开Chrome开发工具,然后选中“ 网络”标签下的“ 禁用缓存”选项。

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM