htaccess的不工作 - 只缓存图像不JS或CSS缓存、图像、工作、htaccess

2023-09-02 00:42:17 作者:山奈

为什么不是我的JavaScript和放大器; CSS缓存?

我注意到,我只接收304 HTTP codeS(缓存内容)的图像,但不是的JavaScript或CSS。

我的.htaccess文件是:

My .htaccess file is:

Options -Indexes
Options +FollowSymLinks  

# Enable ETag
FileETag MTime Size

# Set expiration header
ExpiresActive on
ExpiresDefault "access plus 1 week"

# Compress some text file types
AddOutputFilterByType DEFLATE text/html text/plain text/css text/xml application/x-javascript text/javascript application/javascript application/json

# Deactivate compression for buggy browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html

# Set header information for proxies
Header append Vary User-Agent

任何人都知道为什么只有图像的缓存,而不是我的JavaScript或CSS?

推荐答案

使用像一个小提琴手Snooping代理,看看有什么浏览器请求你的服务器,并正在返回的头。

Use a snooping proxy like Fiddler to see what the browser is requesting of your server and the headers that are being returned.

您应该看到一个200状态的初始请求返回。然后,你应该看到从浏览器的请求,以验证它的高速缓存。返回头应指示浏览器缓存还是不错的,不应该包括页面内容。

You should see an initial request with a "200" status returned. Then you should see a request from the browser to verify its cache. The return header should indicate that the browser cache is still good and should not include the page content.

 
精彩推荐