OLD | NEW |
(Empty) | |
| 1 import time |
| 2 |
| 3 body = ''' |
| 4 onactivate = (e) => e.waitUntil(clients.claim()); |
| 5 var resolve_wait_until; |
| 6 var wait_until = new Promise(resolve => { |
| 7 resolve_wait_until = resolve; |
| 8 }); |
| 9 onmessage = (e) => { |
| 10 if (e.data == 'wait') |
| 11 e.waitUntil(wait_until); |
| 12 if (e.data == 'go') |
| 13 resolve_wait_until(); |
| 14 };''' |
| 15 |
| 16 def main(request, response): |
| 17 headers = [('Cache-Control', 'no-cache, must-revalidate'), |
| 18 ('Pragma', 'no-cache'), |
| 19 ('Content-Type', 'application/javascript')] |
| 20 |
| 21 skipWaiting = '' |
| 22 if 'skip-waiting' in request.GET: |
| 23 skipWaiting = 'skipWaiting();' |
| 24 |
| 25 return headers, '/* %s %s */ %s %s' % (time.time(), time.clock(), skipWaitin
g, body) |
OLD | NEW |