fix: prevent YouTube API quota exhaustion (#1157)#1175
Merged
bcordis merged 4 commits intodevelopmentfrom Mar 19, 2026
Merged
Conversation
…conditions Move YouTube persistent cache files (throttle, quota counter, last-known-video) from JPATH_CACHE to JPATH_ROOT/media/com_proclaim/youtube_cache/ so Joomla "Clear Cache" no longer resets quota protection. Add file locking (flock) to search throttle reads/writes to prevent concurrent requests from both triggering 100-unit search.list calls. Increase default search throttle TTL from 15 minutes to 1 hour, reducing worst-case search.list calls 4x. JS polling improvements: stop polling when quotaRemaining < 100 (reserves units for search.list on page loads), force max backoff when < 500, and deduplicate polling timers across module instances sharing the same server+video URL. Add cache scrub method that removes expired throttle, schedule, quota, and corrupted files — runs automatically in the platform stats scheduled task. Closes #1157 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevents quota_*.json, throttle, and other runtime YouTube cache files from syncing between dev sites, which could cause cross-site quota counter conflicts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use a hash of JPATH_CACHE as a subdirectory so multiple Joomla sites sharing the same repo via symlinks don't share quota counters and throttle files. In production each site has its own media directory, so this is just extra safety. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Now that cache is namespaced by site hash subdirectories, ignore the whole directory tree rather than just *.json files. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Summary
Fixes persistent YouTube API quota exhaustion on sites using
mod_proclaim_youtubeinlive_firstmode, despite v10.2.0 quota optimizations.Root cause analysis
The 10,000 daily quota was being consumed through a combination of:
Fixes
media/com_proclaim/youtube_cache/{hash}/)JPATH_CACHEhash subdirectoryflock()prevents race condition where concurrent requests both trigger search.listmedia/youtube_cache/Estimated impact: Daily quota burn drops from ~17,700 to ~2,000-3,000 units.
Runtime directory creation
The
youtube_cache/directory is not in the build package — it's created automatically at runtime byensureDir()on first use. Existing files from the oldJPATH_CACHElocation are auto-migrated.Test plan
media/com_proclaim/youtube_cache/{hash}/are NOT deleted{hash}/subdirectory with separate quota counterslive_firstmode with no stream → verify search throttled for 1 hour (check log)Closes #1157
🤖 Generated with Claude Code