Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add caching headers for Next.js static assets#330

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
jawnsy merged 1 commit intomainfromjawnsy/chore-add-caching
Feb 19, 2022

Conversation

jawnsy
Copy link

@jawnsyjawnsy commentedFeb 19, 2022
edited
Loading

Default page has no caching:

image

Immutable cache-control for Next.js assets:

image

API calls not cached:

image

Other static content outside_next/static not cached:

image

@codecov
Copy link

codecovbot commentedFeb 19, 2022
edited
Loading

Codecov Report

Merging#330 (d5d9052) intomain (5ef59e7) willincrease coverage by4.05%.
The diff coverage is100.00%.

Impacted file tree graph

@@            Coverage Diff             @@##             main     #330      +/-   ##==========================================+ Coverage   63.61%   67.66%   +4.05%==========================================  Files          69      140      +71       Lines         786     7425    +6639       Branches       77       77              ==========================================+ Hits          500     5024    +4524- Misses        271     1893    +1622- Partials       15      508     +493
FlagCoverage Δ
unittest-go-macos-latest66.34% <100.00%> (?)
unittest-go-ubuntu-latest67.69% <100.00%> (?)
unittest-go-windows-latest65.92% <100.00%> (?)
unittest-js63.61% <ø> (ø)
Impacted FilesCoverage Δ
site/nextrouter/nextrouter.go81.52% <100.00%> (ø)
database/postgres/postgres.go70.73% <0.00%> (ø)
coderd/coderdtest/coderdtest.go100.00% <0.00%> (ø)
httpmw/organizationparam.go69.81% <0.00%> (ø)
pty/start_windows.go52.25% <0.00%> (ø)
pty/pty.go0.00% <0.00%> (ø)
site/embed.go83.14% <0.00%> (ø)
codersdk/projectimport.go64.40% <0.00%> (ø)
httpmw/userparam.go76.66% <0.00%> (ø)
peerbroker/listen.go84.80% <0.00%> (ø)
... and62 more

Continue to review full report at Codecov.

Legend -Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered byCodecov. Last update5ef59e7...d5d9052. Read thecomment docs.

@jawnsyjawnsy self-assigned thisFeb 19, 2022
@jawnsyjawnsy marked this pull request as ready for reviewFebruary 19, 2022 03:02
Comment on lines +81 to +83
ifstrings.HasPrefix(request.URL.Path,"/_next/static/") {
writer.Header().Add("Cache-Control","public, max-age=31536000, immutable")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks great! Thanks for bringing this over@jawnsy 👍

Comment on lines +400 to +402
res,err:=request(server,"/index.html")
require.NoError(t,err)
require.NoError(t,res.Body.Close())
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice tests 👍

@jawnsyjawnsy merged commitf7b4849 intomainFeb 19, 2022
@jawnsyjawnsy deleted the jawnsy/chore-add-caching branchFebruary 19, 2022 03:34
@jawnsyjawnsy removed their assignmentMar 12, 2022
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@kylecarbskylecarbsAwaiting requested review from kylecarbs

1 more reviewer

@bryphe-coderbryphe-coderbryphe-coder approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

2 participants

@jawnsy@bryphe-coder

[8]ページ先頭

©2009-2025 Movatter.jp