mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-29 10:57:44 +09:00 
			
		
		
		
	Instead of statically hardcoding every frontend asset, this uses a type-based approach to cache all js,css and manifest.json requests. This also fixes the issue that the service worker was interfering with EventSource because it was unconditionally handling all requests which this new implementation doesn't. Fixes: https://github.com/go-gitea/gitea/issues/11092 Fixes: https://github.com/go-gitea/gitea/issues/7372
		
			
				
	
	
		
			15 lines
		
	
	
		
			336 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			15 lines
		
	
	
		
			336 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| import {registerRoute} from 'workbox-routing';
 | |
| import {StaleWhileRevalidate} from 'workbox-strategies';
 | |
| 
 | |
| const cachedDestinations = new Set([
 | |
|   'manifest',
 | |
|   'script',
 | |
|   'style',
 | |
|   'worker',
 | |
| ]);
 | |
| 
 | |
| registerRoute(
 | |
|   ({request}) => cachedDestinations.has(request.destination),
 | |
|   new StaleWhileRevalidate({cacheName: 'static-cache-v2'}),
 | |
| );
 |