[英]Strange cache behavior with Symfony2
So I'm having a weird problem with Symfony's cache that seems to be triggered by the asset() function. 所以我在Symfony的缓存中遇到了一个奇怪的问题,该问题似乎是由asset()函数触发的。
My template has this line: <link rel="stylesheet" type="text/css" href="{{ asset('public/login/css/layouts.css') }}" />
我的模板包含以下行: <link rel="stylesheet" type="text/css" href="{{ asset('public/login/css/layouts.css') }}" />
Changes to this CSS-file will not appear in the browser. 对此CSS文件的更改将不会显示在浏览器中。 I tried to clear browser cache, rm -rf app/cache/*
and adding a version number to the link. 我试图清除浏览器缓存, rm -rf app/cache/*
并向链接添加版本号。 Nothing did work. 什么也没做。
When I change the link by simply removing the asset-function and directly link to the file, I see the changes. 当我通过简单地删除资产功能并直接链接到文件来更改链接时,我看到了更改。 Changing the link back will show me the old css-file. 改回链接将显示旧的css文件。 What I don't understand is that the HTML-file that is sent to the browser is exactly the same . 我不明白的是,发送到浏览器的HTML文件是完全相同的 。 The link to the CSS-file does not change at all but the content in the CSS-file does change. 指向CSS文件的链接完全不变,但是CSS文件中的内容确实发生了变化。
You should save your assets in a bundle and let Symfony handle them. 您应该将资产保存在捆绑包中,然后让Symfony处理它们。 After a change, be sure to run: 更改后,请确保运行:
php app/console assets:install web
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.