Skip to content

fix: increase ISR revalidation interval from 30s to 300s on content p… - #1825

Merged
arnoldcastro5000 merged 1 commit into
Greenstand:mainfrom
arnoldcastro5000:fix/increase-isr-revalidation-interval
Jun 10, 2026
Merged

arnoldcastro5000 merged 1 commit into
Greenstand:mainfrom
arnoldcastro5000:fix/increase-isr-revalidation-interval

Conversation

@arnoldcastro5000

@arnoldcastro5000 arnoldcastro5000 commented May 15, 2026 •

Copy link
Copy Markdown
Collaborator

Description

Increases the default ISR revalidation interval from 30s to 300s across all
active content pages (planters, organizations, trees, captures, wallets, top).

NEXT_CACHE_REVALIDATION_OVERRIDE env var is still respected and takes
precedence if set. src/models/utils.js is intentionally left at 30s — that
path handles error recovery retries, where faster revalidation is appropriate.

These are low-churn content pages. A 30s revalidation cycle generates
continuous background regeneration work with no meaningful freshness benefit
to users. This follows the previous PR disabling the in-memory ISR cache in
favour of disk cache for Kubernetes compatibility. With that change in place,
each revalidation triggers a disk write cycle — reducing frequency by 10x
reduces that churn accordingly.

Pages will show data up to 5 minutes stale after an update vs 30 seconds
previously. For these content types this is acceptable.

As follow up to PR #1824
Related fix for issue Greenstand/treetracker-infrastructure#306
Related fix for issue Greenstand/treetracker-infrastructure#300

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Screenshots

N/A — no UI changes.

How Has This Been Tested?

  • Cypress integration
  • Cypress component tests
  • Jest unit tests

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works - see PR test: Cypress regression and cache-header tests for ISR changes #1826
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@arnoldcastro5000

Copy link
Copy Markdown
Collaborator Author

@dadiorchen , related to #1824

@arnoldcastro5000

Copy link
Copy Markdown
Collaborator Author

✅ Cypress integration tests passed in local dev server — pages render correctly
✅ Cypress E2E tests passed against local production build — cache headers and disk cache behavior confirmed

@arnoldcastro5000

Copy link
Copy Markdown
Collaborator Author

(for src/pages/planters/[planterid].js, src/pages/trees/[treeid].js,
src/pages/organizations/[organizationid].js, src/pages/wallets/[walletid].js,
src/pages/v2/captures/[captureid].js, src/pages/top.js):

There's a subtle JavaScript behavior in this line that's worth knowing about:

revalidate: Number(process.env.NEXT_CACHE_REVALIDATION_OVERRIDE) || 300

In JavaScript, the number 0 is treated as "falsy" — the same as false or empty. So if someone sets
NEXT_CACHE_REVALIDATION_OVERRIDE=0 in the environment (thinking it would disable caching or set a
zero-second interval), Number("0") evaluates to 0, which is falsy, and the || 300 fallback takes
over. The result is 300, not 0.

This isn't a bug introduced by this PR — it's a pre-existing pattern across all these files. But
it's worth knowing: the env var only works reliably for values greater than zero. If you ever need
to test with a very short revalidation window, use a small positive number like 5 instead of 0.

@dadiorchen dadiorchen left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me

@arnoldcastro5000
arnoldcastro5000 merged commit 28d452b into Greenstand:main Jun 10, 2026
3 checks passed
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 2.9.10 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@arnoldcastro5000

arnoldcastro5000 commented Jun 10, 2026 •

Copy link
Copy Markdown
Collaborator Author

new image deployed:

arnold@kali:~/projects/greenstand$ kubectl get pods -n webmap
doctl: 2026/06/10 07:05:26 Using cached credential
NAME                                                 READY   STATUS             RESTARTS   AGE
postgrest-59fd45b697-qrjqf                           1/1     Running            0          7d10h
treetracker-query-api-5f9887f546-vt28w               1/1     Running            0          7d10h
treetracker-web-map-client-alpha-ccc657f7f-7j6lb     1/1     Running            0          7d10h
treetracker-web-map-client-beta-77bb8fbff4-js2bc     0/1     ImagePullBackOff   0          7d10h
treetracker-web-map-client-beta-79d6b8947-xrtng      0/1     ImagePullBackOff   0          7d10h
treetracker-web-map-client-deploy-676477fc65-mhf58   1/1     Running            0          6m54s
webmap-query-service-consumer-54658fcf4-r5862        1/1     Running            0          7d10h

arnold@kali:~/projects/greenstand$ kubectl get pod treetracker-web-map-client-deploy-676477fc65-mhf58 -n webmap -o jsonpath='{.spec.containers[0].image}'
doctl: 2026/06/10 07:06:03 Using cached credential
greenstand/treetracker-web-map-client-dev:2.9.10
arnold@kali:~/projects/greenstand$

300 second cache max age in effect:

arnold@kali:~/projects/greenstand$ curl -sI https://dev.treetracker.org/trees/1088471 | grep -i cache-control
cache-control: s-maxage=300, stale-while-revalidate

arnold@kali:~/projects/greenstand$ curl -sI https://dev.treetracker.org/organizations/1 | grep -i cache-control
cache-control: s-maxage=300, stale-while-revalidate

arnold@kali:~/projects/greenstand$ curl -sI https://dev.treetracker.org/top | grep -i cache-control
cache-control: s-maxage=300, stale-while-revalidate

memory usage baseline:

arnold@kali:~/projects/greenstand$ kubectl top pod -n webmap | grep deploy
doctl: 2026/06/10 07:18:15 Using cached credential
treetracker-web-map-client-deploy-676477fc65-mhf58   0m           172Mi
arnold@kali:~/projects/greenstand$

disk stats baseline:

arnold@kali:~/projects/greenstand$ kubectl exec -n webmap treetracker-web-map-client-deploy-676477fc65-mhf58 -- du -sh /app/.next/cache
doctl: 2026/06/10 07:20:33 Using cached credential
187.0M  /app/.next/cache

arnold@kali:~/projects/greenstand$ kubectl exec -n webmap treetracker-web-map-client-deploy-676477fc65-mhf58 -- iostat -d -k 5 3
doctl: 2026/06/10 07:21:51 Using cached credential
Linux 6.1.0-48-amd64 (treetracker-web-map-client-deploy-676477fc65-mhf58)       06/10/26        _x86_64_      (2 CPU)

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda              52.70      3781.51      1175.28 2438075914  757746565
535357            1.81         0.02        14.17      13682    9136041
vda1             52.70      3781.48      1175.28 2438057894  757746565
0                 0.04         0.02        14.17      13682    9135902
vda14             0.00         0.00         0.00        792          0
vda15             0.00         0.01         0.00       5200          0
vdb               0.00         0.00         0.00        448          0
sda               0.00         0.01         0.00       5541        492
sdb               0.00         0.01         0.00       4581       2396

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda               1.20         9.60        12.80         48         64
535359        233501.40      2736.50   1827208.40      13682    9136042
vda1              1.20         9.60        12.80         48         64
0                 0.00         0.00         0.20          0          1
vda14             0.00         0.00         0.00          0          0
vda15             0.00         0.00         0.00          0          0
vdb               0.00         0.00         0.00          0          0
sda               0.00         0.00         0.00          0          0
sdb               0.00         0.00         0.00          0          0

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
vda              16.40        27.20        86.40        136        432
535361        233502.00      2736.50   1827209.10      13682    9136045
vda1             16.40        27.20        86.40        136        432
0                 0.00         0.00         0.70          0          3
vda14             0.00         0.00         0.00          0          0
vda15             0.00         0.00         0.00          0          0
vdb               0.00         0.00         0.00          0          0
sda               0.00         0.00         0.00          0          0
sdb               0.00         0.00         0.00          0          0

@arnoldcastro5000
arnoldcastro5000 deleted the fix/increase-isr-revalidation-interval branch June 10, 2026 11:44
@arnoldcastro5000

Copy link
Copy Markdown
Collaborator Author

deployed to prod on june 18, 2026. see slack for deployment logs.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants