update-fetch-worker.py (615B)
1 import random 2 import time 3 4 def main(request, response): 5 # no-cache itself to ensure the user agent finds a new version for each update. 6 headers = [(b'Cache-Control', b'no-cache, must-revalidate'), 7 (b'Pragma', b'no-cache')] 8 9 content_type = b'' 10 extra_body = u'' 11 12 content_type = b'application/javascript' 13 headers.append((b'Content-Type', content_type)) 14 15 extra_body = u"self.onfetch = (event) => { event.respondWith(fetch(event.request)); };" 16 17 # Return a different script for each access. 18 return headers, u'/* %s %s */ %s' % (time.time(), random.random(), extra_body)