htaccess的不工作 - 只缓存图像不JS或CSS [英] .htaccess not working - only caching images and not JS or CSS

查看:269
本文介绍了htaccess的不工作 - 只缓存图像不JS或CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么不是我的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.

这篇关于htaccess的不工作 - 只缓存图像不JS或CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆