koajs / static-cache

[MAINTAINERS WANTED] Static cache for koa
293 stars 47 forks source link

Possible to set headers when using this module? #59

Closed zacanger closed 7 years ago

zacanger commented 7 years ago

I'm looking to do something like the following (using koa-router):

router.all('*', async (ctx, next) => {
 assets.forEach((a) => { ctx.append('Link', `<${a}>; rel=preload;`) })
 // call staticCache(publicDirectory, otherOptions)
}

(where assets is some JS and CSS) but don't see a clear way to do this. Is that a possibility currently? What I'm currently doing can be seen here. This just gets a shape like [ { headerName: 'headerValue' } ].

I'm trying to avoid adding a separate middleware before staticCache — I'm trying to control headers only for things that happened to also be served by this middleware.

zacanger commented 7 years ago

I found a workaround that works for my use-case, so I'll close this.