当前位置:首页 > 开发 > 开源软件 > 正文

[Node.js] 学习笔记 - express router

发表于: 2014-04-20   作者:cute.spring   来源:转载   浏览次数:
摘要: 参考: http://stackoverflow.com/questions/12695591/node-js-express-js-how-does-app-router-work The best option is to put all of your static resources under a specific folder. (IE /static) You can the
参考:
http://stackoverflow.com/questions/12695591/node-js-express-js-how-does-app-router-work

The best option is to put all of your static resources under a specific folder. (IE /static) You can then mount static to that path so that it only runs when the path starts with /static:

app.use('/static', express.static(__dirname + '/static'));


In this situation, you'd put this above router. This avoids processing other middleware/the router if a file is present, but to be honest, I doubt you'll gain that much.

You could also use staticCache, which caches static resources in-memory so that you don't have to hit the disk for commonly requested files. (Warning: staticCache will apparently be removed in the future.)

However, I don't think staticCache caches negative answers (when a file does not exist), so it doesn't help if you've put staticCache above router without mounting it to a path.

[Node.js] 学习笔记 - express router

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
1.我选择了eclipse。 当然可能更多的人喜欢用webstorm,这都不是关键 首先在eclipse中安装一下node
1.HelloWorld 方法1,直接运行 安装好node js后,在cmd命令窗口输入node. 然后你可以直接输入:cons
这几天便便都昏昏沉沉的,无意间发现有一个《七天学会NodeJS》的博文,平时便便一律认为神马《21天
http://howtonode.org/how-to-install-nodejs http://www.mcclean-cooper.com/valentino/cygwin_ins
三、使用Node.js进行Web开发   1.安装Express     Express是官方推荐的Web开发框架,功能十分
公司项目告一段落,终于有闲工夫静下心来认真学习了。 最近Node.js吵得火热,身为前端也不得不去了
Node.js[5] connect & express简介 Node.js[4] 第一个模块 Node.js[3] 俯瞰API (整理中) Node.js[
跻身于脚本语言世界的一等公民的行列,官网:http://www.nodejs.org。 Express作为Node.js的开发框
续上篇介绍了第七个ESB应用,本文介绍第八个ESB应用——JMS Router。 说明:本文及后续文章虽非百分
What is flow control? 和其它语言一样,Node.js 在代码编写时,如何组织代码,如何写出clean code
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号