Add cache management and smart delay optimization
- Add subtle "clear cache" link (gear icon) in top-right corner - Implement cache clearing endpoint with user feedback - Fix delay logic to skip delays for cached data - Only apply rate limiting delays when actually scraping fresh data - Add cache size reporting when clearing cache - Improve performance for repeat visits with cached data - Maintain server-friendly rate limiting for fresh scrapes 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+26
@@ -172,6 +172,9 @@
|
||||
<body>
|
||||
<div class="container">
|
||||
<h1>PDGA Player Ratings</h1>
|
||||
<div style="position: absolute; top: 10px; right: 15px;">
|
||||
<a href="#" onclick="clearCache(); return false;" style="color: #ccc; font-size: 10px; text-decoration: none; opacity: 0.3;" title="Clear cache">⚙</a>
|
||||
</div>
|
||||
<div id="loading" class="loading" style="display: none;">Loading ratings...</div>
|
||||
<div id="progress-section" style="display: none;">
|
||||
<div class="progress-container">
|
||||
@@ -512,6 +515,29 @@
|
||||
}, 100);
|
||||
}
|
||||
|
||||
async function clearCache() {
|
||||
try {
|
||||
const response = await fetch('/api/clear-cache', {
|
||||
method: 'POST'
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (data.success) {
|
||||
alert(data.message);
|
||||
// Optionally reload the page to reflect fresh data
|
||||
if (confirm('Reload page to fetch fresh data?')) {
|
||||
location.reload();
|
||||
}
|
||||
} else {
|
||||
alert('Failed to clear cache');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error clearing cache:', error);
|
||||
alert('Error clearing cache');
|
||||
}
|
||||
}
|
||||
|
||||
fetchRatingsWithProgress();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
Reference in New Issue
Block a user