lume
lume copied to clipboard
New middleware for headers
To add custom headers to some urls. So it could support something like this: https://docs.netlify.com/routing/headers/
Did you already start creating the middleware? I started with the TS interfaces. If you have any code I can test with let me know.
No, I didn't start. If you want to give a try, I'll appreciate it :)
I'm guessing this is related, but it would be nice if we could cache HTTP requests. It seems there is middleware for 'no-cache' but when I push a copy of (https://github.com/lumeland/base-blog/)[https://github.com/lumeland/base-blog/] to Vercel it does not cache any HTTP requests. I'm guessing the example at (https://lumeland.github.io/base-blog/)[https://lumeland.github.io/base-blog/] has HTTP headers automatically set within the GitHub service since there does not appear to be anything in the code setting the caching header.
(I just began playing with Lume today. I love it.)
@kuhlaid These middlewares are used only for Deno runtime environment. Vercel doesn't run Deno (just serve statically the pages build by Lume). For cache, Lume has the expires middleware, that set the Expires header to the http responses. I think you can achieve something similar in Vercel by configuring your headers (more info: https://vercel.com/docs/project-configuration#project-configuration/headers)
Thank you @oscarotero. I had tried setting the caching options in a vercel.json configuration but was not able to find a combo of header properties to get caching to fully work. I looked at https://lume-blog.vercel.app/ but it does not use caching. My use-case is at https://schm-website-ymxq58e94-kuhlaid.vercel.app/posts/secondpost/ and the pagefind-ui.js caches but not the /posts/secondpost/. This is with a vercel.json that looks like:
{
"headers": [
{
"source": "/(.*)",
"headers": [
{
"key": "Cache-Control",
"value": "max-age=3600"
}
]
}
]
}
@kuhlaid To me, your configuration works fine. The content is cached the first time and then it uses the cached version:

PD: thanks for your post about Lume :)