get web first then cache self.addEventListener('fetch', (event) => { event.respondWith( fetch(event.request) .then((networkResponse) => { // Clone the response before caching (it can only be read once) return caches.open('dynamic-cache').then((cache) => { cache.put(event.request, networkResponse.clone()); return networkResponse; }); }) .catch(() => { // Fallback to cache if the network request fails (offline) return caches.match(event.request); }) ); }); schedule sql $sql = "SELECT tblGamesBrief.ID as briefID, tblGamesFull.ID as homeID, tblGamesFull.xTeam as homeTeam, tblGamesFull.xDate as xDate, tblGamesFull.xWeek as xWeek, tblGamesFull_1.ID as awayID, tblGamesFull_1.xTeam as awayTeam, (case when (Month(tblGamesFull.xDate)> 5) then Year(tblGamesFull.xDate) else Year(tblGamesFull.xDate) - 1 end) as xYear FROM (tblGamesBrief INNER JOIN tblGamesFull ON tblGamesBrief.xHomeTeam = tblGamesFull.ID) INNER JOIN tblGamesFull AS tblGamesFull_1 ON tblGamesBrief.xVisitingTeam = tblGamesFull_1.ID Where (case when (Month(tblGamesFull.xDate)> 5) then Year(tblGamesFull.xDate) else Year(tblGamesFull.xDate) - 1 end)=$getYear order by tblGamesFull.xDate"; encryption network first for start_url if (event.request.mode === 'navigate') { event.respondWith( // 1. Try the network first fetch(event.request) .then((response) => { // Clone the response so we can put one in cache and return the other const responseToCache = response.clone(); caches.open(CACHE_NAME).then((cache) => { cache.put(event.request, responseToCache); }); return response; }) .catch(() => { // 2. Fallback to cache if network fails (offline) return caches.match(event.request); }) ); } javascriptasync function encryptData(plaintext, hexKey) { // 1. Convert hex key to byte array const keyBuffer = new Uint8Array(hexKey.match(/.{1,2}/g).map(byte => parseInt(byte, 16))); // 2. Import the raw key into Web Crypto API const cryptoKey = await crypto.subtle.importKey( "raw", keyBuffer, { name: "AES-CBC" }, false, ["encrypt"] ); // 3. Generate a random 16-byte initialization vector (IV) const iv = crypto.getRandomValues(new Uint8Array(16)); const encoder = new TextEncoder(); const encodedPlaintext = encoder.encode(plaintext); // 4. Encrypt the data const ciphertextBuffer = await crypto.subtle.encrypt( { name: "AES-CBC", iv: iv }, cryptoKey, encodedPlaintext ); // 5. Convert IV and Ciphertext to Base64 const ivBase64 = btoa(String.fromCharCode(...iv)); const ciphertextBase64 = btoa(String.fromCharCode(...new Uint8Array(ciphertextBuffer))); // 6. Combine them with a colon separator for transmission return `${ivBase64}:${ciphertextBase64}`; } // Execution Example: encryptData("Hello from the browser!", "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914df1a") .then(encryptedString => console.log("Send this to PHP:", encryptedString)); Use code with caution.🐘 PHP Decryption (Server)The PHP script accepts the composite Base64 string, splits it back into the individual IV and ciphertext segments, and decrypts it using the built-in OpenSSL library.php