在Express中提供静态文件 - 是缓存吗? [英] Serving static files in Express - is it cached?

查看:226
本文介绍了在Express中提供静态文件 - 是缓存吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ExpressJS 文档中,无论如何加载文件。我的问题是:当我请求一个静态文件时,每个请求是从磁盘加载文件吗?还是以某种方式缓存?如果是这样,怎么样?

解决方案

Express将自动缓存静态内容。为此,我们需要使用 https://www.npmjs.com/package/cache-control中间件更多信息( http://blog.modulus.io/nodejs-and-express静态内容),这有助于


In the ExpressJS documentation there is nothing about how the files are loaded.

My question is: when I request a static file, is the file loaded form the disk with every request? Or it is somehow cached? If so, how?

解决方案

Express will not automatically cache static content. For that we need to use https://www.npmjs.com/package/cache-control middleware. More info here (http://blog.modulus.io/nodejs-and-express-static-content) which helps

这篇关于在Express中提供静态文件 - 是缓存吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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