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

how to set cache-control per extension type #1200

Closed
ericxin1982 opened this issue Dec 15, 2023 · 8 comments
Closed

how to set cache-control per extension type #1200

ericxin1982 opened this issue Dec 15, 2023 · 8 comments

Comments

@ericxin1982
Copy link

ericxin1982 commented Dec 15, 2023

[### Question
A clear and concise description of your question.
]
(https://stackoverflow.com/questions/32987486/iis-setting-cache-control-header-per-file-type)

Is it possible to achieve this as well?

Thanks
Eric Xin

@Badgerati
Copy link
Owner

Hi @ericxin1982,

One way to achieve this would be to use Pode's Endware, assuming this is static content, you could create an Endware which pattern matches against the supplied Path:

Add-PodeEndware -ScriptBlock {
    if ($WebEvent.Path -ilike '*.html') {
        Set-PodeHeader -Name 'Cache-Control' -Value '<value>'
    }
}

Hope that helps :)

@ericxin1982
Copy link
Author

That is so great, thanks.

@ericxin1982
Copy link
Author

Sorry to ask further.
image
If the Cache-Control has two rows, how to do?

Thanks
Eric Xin

@ericxin1982 ericxin1982 reopened this Dec 20, 2023
@Badgerati
Copy link
Owner

Hi @ericxin1982,

Are you able to show a code example of what you have? Called Set-PodeHeader should override any previously set and force on one header - unless there's a process higher up than Pode setting the header also?

@mdaneri
Copy link
Contributor

mdaneri commented Dec 21, 2023

Let me modify the sample to include the issue

@ericxin1982
Copy link
Author

@Badgerati

I set one cache-control in middleware, and set one in endware, and the endware would overwrite the previous setting. I do not have to have two cache-control, but I just showed you IIS would have two or multiple but pode just can have one only.

Thanks
Eric Xin

@Badgerati
Copy link
Owner

Hi @ericxin1982,

Ah right I see, so you want two. In which case using Add-PodeHeader would do this, as it would "add" multiple versions of that header; calling "set" at any point will override any multiple added values and force it back to just one.

@ericxin1982
Copy link
Author

Got it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants