Draft
Implement cache busting mechanism for JSON configuration files#4
Conversation
Co-authored-by: popnoart <501567+popnoart@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix caching issue for modified JSON
Implement cache busting mechanism for JSON configuration files
Oct 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
JSON configuration files (config.json, calendar.json, tasks.json, etc.) were being aggressively cached by browsers, causing users to see stale data even after saving configuration changes. This resulted in a confusing user experience where changes appeared to not be saved, requiring manual browser cache clearing.
Solution
Implemented a lightweight cache version tracking system that automatically invalidates the browser cache whenever JSON data is modified.
Key Changes
Cache Version Tracking - Added
cache_version.txtfile that maintains a simple integer version number (starts at 1, increments on each change)Helper Functions in bootstrap.php
increment_cache_version()- Increments and saves the version numberget_cache_version()- Retrieves the current version numberAutomatic Cache Invalidation - Cache version is incremented when:
editar_config.phptools/import.phptools/compare.phpPage Reload After Config Save - Modified
footer.phpto automatically reload the page 1 second after configuration changes are saved, forcing the browser to fetch fresh dataUser Experience
Before:
After:
Technical Details
The solution uses a simple file-based versioning approach that requires no external dependencies or database changes. The version number is stored in a plain text file and incremented atomically whenever JSON data is modified. This ensures consistent cache invalidation across all browsers and can be extended in the future to support query parameter-based cache busting for API calls (e.g.,
/data/config.json?v=5).Files Changed: 6 files (+63 lines)
public_html/data/cache_version.txtpublic_html/bootstrap.php,public_html/editar_config.php,public_html/assets/templates/footer.php,public_html/tools/import.php,public_html/tools/compare.phpFixes issue: "Los json se cachean demasiado" (JSON files are cached too much)
Original prompt
Fixes #2
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.