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

Add minimumCacheTTL config for Image Optimization #27200

Merged
merged 5 commits into from
Jul 15, 2021

Conversation

styfle
Copy link
Member

@styfle styfle commented Jul 15, 2021

Feature

  • Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • Related issues linked using fixes #number
  • Integration tests added
  • Documentation added
  • Telemetry added. In case of a feature if it's used or not.
  • Errors have helpful link attached, see contributing.md

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

@ijjk

This comment has been minimized.

ijjk
ijjk previously approved these changes Jul 15, 2021
@ijjk

This comment has been minimized.

@styfle styfle changed the title Add minimumCacheTtl config for Image Optimization Add minimumCacheTTL config for Image Optimization Jul 15, 2021
@styfle styfle requested a review from ijjk July 15, 2021 19:18
@ijjk
Copy link
Member

ijjk commented Jul 15, 2021

Stats from current PR

Default Build (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary vercel/next.js add-image-max-age-config Change
buildDuration 15.7s 15.7s ⚠️ +12ms
buildDurationCached 3.7s 3.6s -119ms
nodeModulesSize 49.4 MB 49.4 MB ⚠️ +1.33 kB
Page Load Tests Overall decrease ⚠️
vercel/next.js canary vercel/next.js add-image-max-age-config Change
/ failed reqs 0 0
/ total time (seconds) 2.682 2.684 0
/ avg req/sec 931.99 931.61 ⚠️ -0.38
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.638 1.69 ⚠️ +0.05
/error-in-render avg req/sec 1526.15 1479.66 ⚠️ -46.49
Client Bundles (main, webpack, commons)
vercel/next.js canary vercel/next.js add-image-max-age-config Change
359.HASH.js gzip 2.96 kB 2.96 kB
framework-HASH.js gzip 42 kB 42 kB
main-HASH.js gzip 20.9 kB 20.9 kB
webpack-HASH.js gzip 1.49 kB 1.49 kB
Overall change 67.4 kB 67.4 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js add-image-max-age-config Change
polyfills-HASH.js gzip 31.1 kB 31.1 kB
Overall change 31.1 kB 31.1 kB
Client Pages Overall increase ⚠️
vercel/next.js canary vercel/next.js add-image-max-age-config Change
_app-HASH.js gzip 803 B 803 B
_error-HASH.js gzip 3.06 kB 3.06 kB
amp-HASH.js gzip 554 B 554 B
css-HASH.js gzip 329 B 329 B
hooks-HASH.js gzip 903 B 903 B
image-HASH.js gzip 5.58 kB 5.6 kB ⚠️ +17 B
index-HASH.js gzip 261 B 261 B
link-HASH.js gzip 1.66 kB 1.66 kB
routerDirect..HASH.js gzip 319 B 319 B
withRouter-HASH.js gzip 320 B 320 B
bb14e60e810b..30f.css gzip 125 B 125 B
Overall change 13.9 kB 13.9 kB ⚠️ +17 B
Client Build Manifests Overall decrease ✓
vercel/next.js canary vercel/next.js add-image-max-age-config Change
_buildManifest.js gzip 418 B 417 B -1 B
Overall change 418 B 417 B -1 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js add-image-max-age-config Change
index.html gzip 531 B 531 B
link.html gzip 545 B 545 B
withRouter.html gzip 526 B 526 B
Overall change 1.6 kB 1.6 kB

Diffs

Diff for _buildManifest.js
@@ -13,7 +13,7 @@ self.__BUILD_MANIFEST = {
     "static\u002Fchunks\u002Fpages\u002Fhooks-4e38b05900fed34fcf34.js"
   ],
   "/image": [
-    "static\u002Fchunks\u002Fpages\u002Fimage-011996dbc6095969738b.js"
+    "static\u002Fchunks\u002Fpages\u002Fimage-84f762b2104d16092912.js"
   ],
   "/link": ["static\u002Fchunks\u002Fpages\u002Flink-36845453cb7a35e1a731.js"],
   "/routerDirect": [
Diff for image-HASH.js
@@ -1551,7 +1551,8 @@
         path: "/_next/image",
         loader: "default",
         domains: [],
-        disableStaticImages: false
+        disableStaticImages: false,
+        minimumCacheTTL: 60
       };
       exports.imageConfigDefault = imageConfigDefault;

Webpack 4 Mode (Increase detected ⚠️)
General Overall increase ⚠️
vercel/next.js canary vercel/next.js add-image-max-age-config Change
buildDuration 12.7s 12.9s ⚠️ +237ms
buildDurationCached 5s 5s -8ms
nodeModulesSize 49.4 MB 49.4 MB ⚠️ +1.33 kB
Page Load Tests Overall increase ✓
vercel/next.js canary vercel/next.js add-image-max-age-config Change
/ failed reqs 0 0
/ total time (seconds) 2.814 2.787 -0.03
/ avg req/sec 888.44 897.14 +8.7
/error-in-render failed reqs 0 0
/error-in-render total time (seconds) 1.638 1.64 0
/error-in-render avg req/sec 1526.39 1524.66 ⚠️ -1.73
Client Bundles (main, webpack, commons)
vercel/next.js canary vercel/next.js add-image-max-age-config Change
14.HASH.js gzip 2.98 kB 2.98 kB
677f882d2ed8..HASH.js gzip 13.7 kB 13.7 kB
framework.HASH.js gzip 41.8 kB 41.8 kB
main-HASH.js gzip 8.39 kB 8.39 kB
webpack-HASH.js gzip 1.19 kB 1.19 kB
Overall change 68 kB 68 kB
Legacy Client Bundles (polyfills)
vercel/next.js canary vercel/next.js add-image-max-age-config Change
polyfills-HASH.js gzip 31.3 kB 31.3 kB
Overall change 31.3 kB 31.3 kB
Client Pages
vercel/next.js canary vercel/next.js add-image-max-age-config Change
_app-HASH.js gzip 791 B 791 B
_error-HASH.js gzip 3.76 kB 3.76 kB
amp-HASH.js gzip 552 B 552 B
css-HASH.js gzip 333 B 333 B
hooks-HASH.js gzip 910 B 910 B
index-HASH.js gzip 230 B 230 B
link-HASH.js gzip 1.64 kB 1.64 kB
routerDirect..HASH.js gzip 297 B 297 B
withRouter-HASH.js gzip 293 B 293 B
e025d2764813..52f.css gzip 125 B 125 B
Overall change 8.93 kB 8.93 kB
Client Build Manifests
vercel/next.js canary vercel/next.js add-image-max-age-config Change
_buildManifest.js gzip 420 B 420 B
Overall change 420 B 420 B
Rendered Page Sizes
vercel/next.js canary vercel/next.js add-image-max-age-config Change
index.html gzip 574 B 574 B
link.html gzip 588 B 588 B
withRouter.html gzip 568 B 568 B
Overall change 1.73 kB 1.73 kB
Commit: 6c4ae02

@kodiakhq kodiakhq bot merged commit 8151a7e into canary Jul 15, 2021
@kodiakhq kodiakhq bot deleted the add-image-max-age-config branch July 15, 2021 19:55
kodiakhq bot pushed a commit that referenced this pull request Jul 19, 2021
In a previous PR (#27200), we added `minimumCacheTTL` to configure the time-to-live for the cached image. However, this was setting the `max-age` header.

This PR ensures that `minimumCacheTTL` doesn't affect browser caching, only the upstream header can affect browser caching.

This is a bit safer in case the developer accidentally caches something that shouldn't be and the cache needs to be invalidated. Simply delete the `.next/cache/images` directory.

- Related to #19914
- Related to #22319
flybayer pushed a commit to blitz-js/next.js that referenced this pull request Aug 19, 2021
- Closes vercel#23328  
- Related to vercel#19914 
- Related to vercel#22319 


## Feature

- [x] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
- [x] Related issues linked using `fixes #number`
- [x] Integration tests added
- [x] Documentation added
- [ ] Telemetry added. In case of a feature if it's used or not.
- [x] Errors have helpful link attached, see `contributing.md`
flybayer pushed a commit to blitz-js/next.js that referenced this pull request Aug 19, 2021
)

In a previous PR (vercel#27200), we added `minimumCacheTTL` to configure the time-to-live for the cached image. However, this was setting the `max-age` header.

This PR ensures that `minimumCacheTTL` doesn't affect browser caching, only the upstream header can affect browser caching.

This is a bit safer in case the developer accidentally caches something that shouldn't be and the cache needs to be invalidated. Simply delete the `.next/cache/images` directory.

- Related to vercel#19914
- Related to vercel#22319
@vercel vercel locked as resolved and limited conversation to collaborators Jan 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants