Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New middleware for headers #183

Open
oscarotero opened this issue Apr 15, 2022 · 6 comments
Open

New middleware for headers #183

oscarotero opened this issue Apr 15, 2022 · 6 comments
Labels
enhancement New feature or request plugins

Comments

@oscarotero
Copy link
Member

To add custom headers to some urls.
So it could support something like this: https://docs.netlify.com/routing/headers/

@oscarotero oscarotero added the enhancement New feature or request label Apr 15, 2022
@jrson83
Copy link
Contributor

jrson83 commented Sep 8, 2022

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.

@oscarotero
Copy link
Member Author

No, I didn't start. If you want to give a try, I'll appreciate it :)

@oscarotero oscarotero added this to the 1.12.0 milestone Sep 10, 2022
@oscarotero oscarotero removed this from the 1.12.0 milestone Sep 30, 2022
@kuhlaid
Copy link

kuhlaid commented Oct 4, 2022

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.)

@oscarotero
Copy link
Member Author

@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)

@kuhlaid
Copy link

kuhlaid commented Oct 5, 2022

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"
                }
            ]
        }
    ]
}

@oscarotero
Copy link
Member Author

@kuhlaid To me, your configuration works fine. The content is cached the first time and then it uses the cached version:
image

PD: thanks for your post about Lume :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request plugins
Projects
None yet
Development

No branches or pull requests

3 participants