在類unix主機(jī)上,文件系統(tǒng)是區(qū)分大小寫的,但在網(wǎng)絡(luò)上卻需要忽略大小寫,比如一些網(wǎng)友上傳照片的時(shí)候,圖片后綴名一般是大寫的。這將會(huì)導(dǎo)致我們前端緩存服務(wù)無法緩存或進(jìn)行重復(fù)緩存,影響效率。
如果使用nginx,在配置location時(shí),可以用~*忽略大小寫,例如:
location ~* \.(ftpquota|htaccess|htpasswd)?$ { # ~*表示忽略大小寫
deny all;
}
配置squid的acl時(shí),可以用-i忽略大小寫,例如:
acl domain dstdomain -i adocode.com(-i表示忽略大小寫)
http_access deny domain
而在varnish的vcl語法中,可以用(?i)的正則表達(dá)式忽略大小寫,例如:
if (req.http.referer !~ "(?i)icodex.org") { # (?i)表示忽略大小寫
error 404;
}