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

feat: add build cache settings #1669

Merged
merged 20 commits into from
May 29, 2023
Merged

feat: add build cache settings #1669

merged 20 commits into from
May 29, 2023

Conversation

sambhavgupta0705
Copy link
Member

@sambhavgupta0705 sambhavgupta0705 commented May 14, 2023

Description

  • tried adding the cache settings for the website

Related issue(s)

fixes #843

@netlify
Copy link

netlify bot commented May 14, 2023

Deploy Preview for asyncapi-website ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit 6c653f3
🔍 Latest deploy log https://app.netlify.com/sites/asyncapi-website/deploys/647480b5694c280008caa54f
😎 Deploy Preview https://deploy-preview-1669--asyncapi-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@sambhavgupta0705 sambhavgupta0705 marked this pull request as draft May 14, 2023 12:32
@sambhavgupta0705 sambhavgupta0705 marked this pull request as ready for review May 14, 2023 15:17
@github-actions
Copy link

github-actions bot commented May 14, 2023

⚡️ Lighthouse report for the changes in this PR:

Category Score
🔴 Performance 48
🟢 Accessibility 98
🟢 Best practices 100
🟢 SEO 100
🔴 PWA 30

Lighthouse ran on https://deploy-preview-1669--asyncapi-website.netlify.app/

@derberg
Copy link
Member

derberg commented May 15, 2023

can you explain what you added and why and basing on what docs?

also, why we need netlify cli in the dependencies ?

@sambhavgupta0705
Copy link
Member Author

sambhavgupta0705 commented May 15, 2023

can you explain what you added and why and basing on what docs?

I went through the netlify blogs and found that we need to install the plugins for nextjs site deployed on netlify to enable caching
https://github.com/netlify/next-runtime#use-with-next-export

also, why we need netlify cli in the dependencies ?

Sorry I forgot to mention I need to check the deploy status so needed to install it .I will remove it before the final merge

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

if you just need netlify cli for local testing then just remove it not and use it through npx

netlify.toml Outdated
@@ -1,6 +1,7 @@
[[headers]]
for = "/*"
[headers.values]
Cache-Control = "public, max-age=3600"
Copy link
Member

Choose a reason for hiding this comment

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

the scope of the issue is to enable cache for build,

why is this header added? what will it change?

Copy link
Member Author

Choose a reason for hiding this comment

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

it is added to control how caching should be performed
The value public, max-age=3600 specifies that the response can be cached by both public and private caches
,and the caching age is 3600 seconds

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

yes but how is it helping with cache build? this is a setting for the server and client side caching. So imho totally unrelated and probably something we should not add

Copy link
Member Author

Choose a reason for hiding this comment

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

well it just tell the server how long the response should be considered fresh and cacheable.So we can remove it as it doesn't help us that much in build

netlify.toml Show resolved Hide resolved
@derberg
Copy link
Member

derberg commented May 15, 2023

cache is working

this is build info from your PR. First one, and logs were saying no cache found - which makes sense
Screenshot 2023-05-15 at 14 13 14

then this is a rerun, and logs mentioned cache is use
Screenshot 2023-05-15 at 14 13 21

so we have 1min improvement. Looks like it works. So please just answer the questions to the PR

@sambhavgupta0705
Copy link
Member Author

cache is working

nice I was worried what would be the outcome :)

@sambhavgupta0705
Copy link
Member Author

@derberg PTAL

Copy link
Member Author

@sambhavgupta0705 sambhavgupta0705 left a comment

Choose a reason for hiding this comment

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

I have added the comments

netlify.toml Show resolved Hide resolved
netlify.toml Show resolved Hide resolved
netlify.toml Outdated
@@ -1,6 +1,7 @@
[[headers]]
for = "/*"
[headers.values]
Cache-Control = "public, max-age=3600"
Copy link
Member Author

Choose a reason for hiding this comment

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

it is added to control how caching should be performed
The value public, max-age=3600 specifies that the response can be cached by both public and private caches
,and the caching age is 3600 seconds

netlify.toml Show resolved Hide resolved
netlify.toml Show resolved Hide resolved
netlify.toml Outdated
@@ -1,6 +1,7 @@
[[headers]]
for = "/*"
[headers.values]
Cache-Control = "public, max-age=3600"
Copy link
Member

Choose a reason for hiding this comment

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

yes but how is it helping with cache build? this is a setting for the server and client side caching. So imho totally unrelated and probably something we should not add

netlify.toml Show resolved Hide resolved
@sambhavgupta0705
Copy link
Member Author

sambhavgupta0705 commented May 17, 2023

@derberg all the things are done form my side ,
Should we check that the cache is working or not once more?

@derberg derberg changed the title feat: added cache settings feat: add build cache settings May 22, 2023
derberg
derberg previously approved these changes May 22, 2023
Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

@sambhavgupta0705 lgtm, just update description that this PR fixes linked issue so it is closed after merge

@akshatnema anything from your side?

@akshatnema akshatnema linked an issue May 23, 2023 that may be closed by this pull request
@akshatnema
Copy link
Member

@derberg My concern over the implementation is that aren't we targeting the posts.json content to cache it inside website? With the current implementation inside this PR, I can't figure what content are we caching inside Netlify?

@derberg
Copy link
Member

derberg commented May 23, 2023

@akshatnema this PR and related issue is focused on build cache, not website cache. It is not focused on website performance after deployment but the build performance and its speed. In other words, this PR enables cache inside Netlify build cache, to cache not only posts.json but also other source files, to speed up website rebuild.

So website is not faster thanks to this PR. What is faster is the rebuild of for example preview in the PRs and contribution flow is improved

@akshatnema
Copy link
Member

akshatnema commented May 23, 2023

@derberg Yeah, I completely understand that it is not building in any cache inside website runtime, but it should build a cache for posts.json and shouldn't run the build of the posts.json every time the build has been initiated.

Also, I see the following error regarding the npm packages:
image

So, probably, we have to upgrade the node version of Netlify.

@sambhavgupta0705 You have to use Node v16.15.0 and npm v8.5.5 here.

Copy link
Member

derberg commented May 23, 2023

@sambhavgupta0705 the change needs to be done in netlify.toml file

@akshatnema regarding posts.json, I don't think there is any specific solution that we can add that will enable that. Building posts.json is a custom script, so what you are suggesting is like adding if into script, that in case for example there were no changes in docs detected, then docs script should basically not run. Or did you have some other idea?

Copy link
Member

@derberg For now, I can't able to find anything in the Netlify docs to cache any existing files. Hope we had any CMS or DB for the posts in future so that we can set some caching regarding those in future. So approved ✅

Copy link
Member

@sambhavgupta0705 Kindly resolve the conflicts.

@sambhavgupta0705
Copy link
Member Author

@akshatnema done 👍🏻

Copy link
Member

@derberg derberg left a comment

Choose a reason for hiding this comment

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

Thanks!

@derberg
Copy link
Member

derberg commented May 29, 2023

/rtm

@derberg derberg merged commit 80eca5e into asyncapi:master May 29, 2023
@asyncapi-bot asyncapi-bot added the bounty AsyncAPI Bounty program related label label Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty AsyncAPI Bounty program related label
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

Consider enabling Next.js caching for Netlify builds
4 participants