2017-02-28 93 views
1

我正在处理一个角度2项目,我希望我的浏览器在每次部署后从服务器请求新文件。我怎样才能做到这一点?高速缓冲存储器在角2

备注:

我在apache的.htaccess文件中启用缓存。

我目前使用的是角度cli 1.0.0-beta.22-1。

编辑: 每次我运行“NG打造--prod”从角CLI,我希望它以某种方式加入快取清除像filename.js所有编辑的文件

+0

+0

试试添加^^这到您的索引页 –

+0

@ArnrnathRShenoy感谢您的评论,但我认为这完全关闭浏览器缓存,这不是我想要的。我想启用缓存,但每次我从角度cli运行“ng build --prod”时,我希望它以某种方式添加一个像filename.js?ver = 1.0.2的缓存拦截器。 – mattdapope

回答

0

在版本1.0.2 =?角色cli版本1.0.0-rc.0有一个build命令:

--output-hashing = none | all | media | bundles(字符串)定义输出文件名cache-busting哈希模式。

0

现在这个存在于@angular/cli 1.6.0按照意见在这里:

,允许输出散列进行配置#3885

https://github.com/angular/angular-cli/pull/3885

这使得输出文件名散列将通过一个新的构建过程中配置建立命令选项

--output-hashing. 

有四种可能的值:

none: no hashing performed 
media: only add hashes to files processed via [url|file]-loaders 
bundles: only add hashes to the output bundles 
all: add hashes to both media and bundles 

没有一个是开发目标的默认值。 全部是生产目标的默认值。

相关问题