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