Aichatbot12321 commited on
Commit
90e25fa
·
verified ·
1 Parent(s): ef0e76a

Update sw.js

Browse files
Files changed (1) hide show
  1. sw.js +11 -23
sw.js CHANGED
@@ -1,27 +1,20 @@
1
- const CACHE_NAME = 'deep-ai-pro-v2'; // नया वर्ज़न
2
 
3
- // बस काम की चीजें सेव करेंगे
4
  const STATIC_ASSETS = [
5
- '/',
6
- '/index.html',
7
- '/search.html',
8
- '/maths.html',
9
- '/style.css',
10
- '/main.js',
11
- '/manifest.json'
12
  ];
13
 
14
- // इंस्टॉल होते ही तुरंत एक्टिवेट हो जाए
15
  self.addEventListener('install', (e) => {
16
  self.skipWaiting();
17
- e.waitUntil(
18
- caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS))
19
- );
20
  });
21
 
22
  self.addEventListener('activate', (e) => {
23
  e.waitUntil(clients.claim());
24
- // पुराना कचरा (v1) साफ कर दे
25
  e.waitUntil(
26
  caches.keys().then((keys) => {
27
  return Promise.all(keys.map((key) => {
@@ -31,25 +24,20 @@ self.addEventListener('activate', (e) => {
31
  );
32
  });
33
 
34
- // 🧠 SMART FETCH (NETWORK FIRST)
35
  self.addEventListener('fetch', (e) => {
36
- // 🚨 POST रिक्वेस्ट (Gemini, Groq, Firecrawl) को बिल्कुल मत छेड़ो! सीधा इंटरनेट पर जाने दो।
37
- if (e.request.method !== 'GET') {
38
- return;
39
- }
40
 
41
- // NETWORK FIRST: पहले इंटरनेट से नया डेटा लाओ, अगर नेट बंद है तब Cache से दिखाओ
42
  e.respondWith(
43
  fetch(e.request)
44
  .then((response) => {
45
- // अगर इंटरनेट चल रहा है, तो नई फाइल को कैश में भी अपडेट कर दो
46
  const resClone = response.clone();
47
  caches.open(CACHE_NAME).then((cache) => cache.put(e.request, resClone));
48
  return response;
49
  })
50
  .catch(() => {
51
- // अगर इंटरनेट बंद है, तो सेव की हुई फाइल दिखा दो
52
- return caches.match(e.request);
 
53
  })
54
  );
55
  });
 
1
+ const CACHE_NAME = 'deep-ai-pro-v3';
2
 
3
+ // 🚀 तुम्हारे सारे पेज यहाँ डाल दिए हैं!
4
  const STATIC_ASSETS = [
5
+ '/', '/index.html', '/search.html', '/maths.html', '/style.css', '/main.js', '/manifest.json',
6
+ '/history.html', '/image.html', '/board.html', '/youtube.html', '/translator.html',
7
+ '/qa.html', '/quiz.html', '/lens.html', '/create.html', '/books.html', '/book_quiz.html',
8
+ '/tables.html', '/chess.html', '/runhtml.html'
 
 
 
9
  ];
10
 
 
11
  self.addEventListener('install', (e) => {
12
  self.skipWaiting();
13
+ e.waitUntil(caches.open(CACHE_NAME).then((cache) => cache.addAll(STATIC_ASSETS)));
 
 
14
  });
15
 
16
  self.addEventListener('activate', (e) => {
17
  e.waitUntil(clients.claim());
 
18
  e.waitUntil(
19
  caches.keys().then((keys) => {
20
  return Promise.all(keys.map((key) => {
 
24
  );
25
  });
26
 
 
27
  self.addEventListener('fetch', (e) => {
28
+ if (e.request.method !== 'GET') return;
 
 
 
29
 
 
30
  e.respondWith(
31
  fetch(e.request)
32
  .then((response) => {
 
33
  const resClone = response.clone();
34
  caches.open(CACHE_NAME).then((cache) => cache.put(e.request, resClone));
35
  return response;
36
  })
37
  .catch(() => {
38
+ // 🔥 THE MAGIC FIX: ignoreSearch: true
39
+ // यह URL के आगे लगे ?session=123 को इग्नोर करके पेज को ऑफलाइन भी लोड कर देगा!
40
+ return caches.match(e.request, { ignoreSearch: true });
41
  })
42
  );
43
  });