npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

koa-static-etag

v1.0.1

Published

静态资源启用304缓存机制

Downloads

6

Readme

koa-static-etag

Installation

Install the plugin with npm:

$ npm install koa-static-etag --save-dev

API

const Koa = require('koa');
const app = new Koa();
app.use(require('koa-static-etag')(opts));

Options

  • mode 可以是'etag'、'lastModified'、true 、false四种选项 如果是lastModified,则启用Last-Modified机制.如果是false,则不进行304机制检测。默认是 true,使用Etag机制.
  • root 静态资源的根目录, 默认是 process.cwd().
  • pathMatch 请求路径的匹配规则,可以是 字符串、正则或者函数(返回true或者false,参数是当前url请求的路径)
  • extMatch 请求文件后缀名的可以进行Etag或lastModified的规则匹配,可以是 字符串、正则或者函数(返回true或者false,参数是当前请求文件的扩展名)
  • index 请求的默认文件,防止当前请求没有文件响应,默认是'index.html'

Example

let koa = require('koa2');    
let app = new koa();
let staticEtag = require('koa-static-etag')
    
app.use(staticEtag({
    root: __dirname,
    pathMatch: /^(\/tm-admin)|(\/static)/, //tm-admin和static目录下可以返回静态资源
    extMatch: /[^(mp4)]$/i,  //MP4格式的视频不进行304缓存
    mode:true
}))