Skip to content

fix cache control for static page with base path #880

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

conico974
Copy link
Contributor

Fixes #872

Copy link

changeset-bot bot commented May 25, 2025

🦋 Changeset detected

Latest commit: 6f7c130

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@opennextjs/aws Patch
app-pages-router Patch
app-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

pkg-pr-new bot commented May 25, 2025

Open in StackBlitz

pnpm add https://pkg.pr.new/@opennextjs/aws@880

commit: 6f7c130

@@ -245,7 +245,9 @@ export function fixCacheHeaderForHtmlPages(
// https://opennext.js.org/aws/v2/advanced/workaround#workaround-nextserver-does-not-set-cache-headers-for-html-pages
// Requests containing an `x-middleware-prefetch` header must not be cached
if (
HtmlPages.includes(localizedPath) &&
HtmlPages.find(
(path) => `${NextConfig.basePath ?? ""}${path}` === localizedPath,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: instead of having to string concat time, you could compare to localizedPathFromBasePath that would be computed once before the loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ho this made me realize, this might not be correct when both i18n and basePath are set.
I'll convert this one to draft and make a release in the meantime

Copy link
Contributor

@vicb vicb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Suggested an optim

@conico974 conico974 marked this pull request as draft May 27, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cache control headers not set for static page with base path
2 participants