0
我使用缓存清除机制,其中包含版本名称在我的页面上的每个资源。如何从文件请求中正确删除版本名称?
实施例:
<link rel="stylesheet" type="text/css" href="styles/viewnote.<?php echo VERSION; ?>.css" />
输出:
<link rel="stylesheet" type="text/css" href="styles/viewnote.100.css" />
真正的文件的名称是viewnote.css少,所以需要使用htaccess的删除的版本号。
我用这个example:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)\.(\d+)\.(js|css|png|jpg|gif)$ $1.$3 [L]
,但它不工作:
难道你不能让版本像'viewnote.css?110'一样吗? – developerwjk
我可以但[链接](https://css-tricks.com/strategies-for-cache-busting-css/)建议使用我选择的方法。 – ondrejba
重写规则中的“\”是否正确?我看到它是:'RewriteRule ^(。+)。(d +)。(js | css)$ $ 1. $ 3 [L]' – camelCase