javascript - 关于缓存的问题
PHP中文网
PHP中文网 2017-04-11 10:56:27
[JavaScript讨论组]

我用express框架做的后台,当我关闭etag,并设置maxAge时,静态资源有时候出现200 OK (from memory cache) 有时候出现200 OK (from disk cache),那么这两者有什么区别吗?
还有的时候会出现Status Code:304 Not Modified,这又是怎么回事?不是应该直接从缓存里取数据,不用和服务器交互吗?

代码如下:

app.use(express.static(path.join(__dirname, 'build'), { //build文件夹是打包后的文件夹
     maxAge: 86400000,
     etag: false
}));

network下的一些信息:

1):
General
Request URL:http://localhost:18081/monitor/fmc/assets/js/echarts-theme.js
Request Method:GET
Status Code:304 Not Modified
Remote Address:[::1]:18081

Response Headers
Accept-Ranges:bytes
Cache-Control:public, max-age=86400
Connection:keep-alive
Date:Sat, 24 Dec 2016 09:54:19 GMT
Last-Modified:Tue, 08 Nov 2016 11:31:47 GMT
X-Powered-By:Express

2):
General
Request URL:http://localhost:18081/monitor/fmc/assets/images/bg-out.jpg
Request Method:GET
Status Code:200 OK (from memory cache)
Remote Address:[::1]:18081

Response Headers
Accept-Ranges:bytes
Cache-Control:public, max-age=86400
Connection:keep-alive
Content-Length:446462
Content-Type:image/jpeg
Date:Sat, 24 Dec 2016 09:53:56 GMT
Last-Modified:Sat, 26 Nov 2016 01:16:49 GMT
X-Powered-By:Express
PHP中文网
PHP中文网

认证0级讲师

全部回复(0)
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号