Skip to content

fix: Firefox stale-cache ReferenceError on writer pages (#151)#153

Merged
sjordan0228 merged 2 commits into
devfrom
fix/firefox-shared-js-cache
Apr 13, 2026
Merged

fix: Firefox stale-cache ReferenceError on writer pages (#151)#153
sjordan0228 merged 2 commits into
devfrom
fix/firefox-shared-js-cache

Conversation

@sjordan0228
Copy link
Copy Markdown
Contributor

@sjordan0228 sjordan0228 commented Apr 13, 2026

Summary

  • Firefox cached shared.js from a previous firmware with max-age=86400, causing sharedWriteFlow is not defined on all writer pages
  • Changed Cache-Control for shared.css and shared.js to no-store — browsers never cache these files again
  • Added ?v=FIRMWARE_VERSION query string to all shared.css / shared.js references to bust existing stale caches immediately on first load
  • Version is wired to the FIRMWARE_VERSION build flag via C string literal concatenation — auto-updates with every release, no manual step needed
  • Pinned espressif32@6.10.0 to prevent Arduino 3.x auto-upgrade breaking the build

Fixes #151

Test plan

  • Load writer page in Firefox — confirm no sharedWriteFlow is not defined error
  • Load writer page in Chrome — confirm no regressions
  • Check page source — confirm ?v=1.7.0 appears on shared.css and shared.js references
  • Bump FIRMWARE_VERSION in platformio.ini, rebuild — confirm version string updates in compiled HTML

Summary by CodeRabbit

  • Chores

    • Pinned ESP32 platform to version 6.10.0 for build consistency
  • Bug Fixes

    • Updated asset caching behavior to ensure users receive fresh stylesheets and scripts when firmware updates are installed
    • Added firmware version identifiers to all static asset requests across web interface pages

Firefox cached shared.js from a previous firmware with max-age=86400,
causing sharedWriteFlow is not defined on all writer pages.

- Append ?v=1.7.0 to all shared.js and shared.css references so existing
  stale caches are bypassed immediately on next page load
- Change Cache-Control from max-age=86400 to no-store so future firmware
  updates can never produce this same stale-function error again

Fixes #151
Replace hardcoded ?v=1.7.0 with compile-time FIRMWARE_VERSION concatenation
so the cache-bust query string automatically tracks the firmware version.
Also pin espressif32@6.10.0 to prevent Arduino 3.x auto-upgrade.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: e7307af1-3e78-4a2e-a7f5-0ba0081489d3

📥 Commits

Reviewing files that changed from the base of the PR and between 640a01a and a969442.

📒 Files selected for processing (13)
  • platformio.ini
  • src/ConfigHTML.h
  • src/LandingHTML.h
  • src/LogViewerHTML.h
  • src/OpenPrintTagWriterHTML.h
  • src/OpenSpoolWriterHTML.h
  • src/OpenTag3DWriterHTML.h
  • src/ReaderHTML.h
  • src/TigerTagWriterHTML.h
  • src/TroubleshootingHTML.h
  • src/UIDRegistrationHTML.h
  • src/UpdateHTML.h
  • src/WebServerManager.cpp

📝 Walkthrough

Walkthrough

The PR implements cache-busting for static assets by appending firmware version query parameters to CSS/JS URLs across HTML templates, updates the ESP32 platform toolchain to an explicit version, and modifies Cache-Control headers for shared static assets to prevent caching.

Changes

Cohort / File(s) Summary
Platform Configuration
platformio.ini
Pinned ESP32 platform toolchain from floating espressif32 to explicit version espressif32@6.10.0.
HTML Cache-Busting
src/ConfigHTML.h, src/LandingHTML.h, src/LogViewerHTML.h, src/OpenPrintTagWriterHTML.h, src/OpenSpoolWriterHTML.h, src/OpenTag3DWriterHTML.h, src/ReaderHTML.h, src/TigerTagWriterHTML.h, src/TroubleshootingHTML.h, src/UIDRegistrationHTML.h, src/UpdateHTML.h
Appended firmware version query parameter (?v=FIRMWARE_VERSION) to all /css/shared.css and /js/shared.js asset URLs for cache-busting purposes.
HTTP Caching Headers
src/WebServerManager.cpp
Changed Cache-Control header for shared CSS/JS endpoints from public, max-age=86400 to no-store to prevent browser caching.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

size/M

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main fix: resolving a Firefox cache issue affecting writer pages with a ReferenceError.
Description check ✅ Passed The description covers all template sections: Summary (root cause and solutions), Changes (Cache-Control, query params, version pinning), and Test plan with checklist items.
Linked Issues check ✅ Passed The PR fully addresses issue #151 by implementing cache-busting (no-store headers and version query strings) and pinning platform version to prevent stale cached JS errors on writer pages.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the Firefox stale-cache issue: platformio.ini pinning, Cache-Control headers, and cache-bust query parameters across all affected HTML files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/firefox-shared-js-cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the size/S Small change (10-50 lines) label Apr 13, 2026
@sjordan0228 sjordan0228 merged commit f8d773e into dev Apr 13, 2026
3 checks passed
@sjordan0228 sjordan0228 deleted the fix/firefox-shared-js-cache branch April 21, 2026 01:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small change (10-50 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant