<commit_before>/**
 * sw.js
 */

let CACHE_NAME = 'yk-blog'

self.oninstall = event => {
  event.waitUntil(
    caches.open(CACHE_NAME).then(cache => cache.addAll([
      '/',
      '/assets/css/main.css',
      '/assets/js/func.js',
      '/assets/js/particles.js',
      '/assets/js/anchor.js'
    ]))
  )
}

self.onfetch = event => {
  event.respondWith(
    caches.match(event.request).then(response => {
      if (response && response.type == 'basic') {
        return response
      }
      return fetch(event.request).then(response => {
        if (response.type == 'basic') {
          return caches.open(CACHE_NAME).then(cache => {
            cache.put(event.request, response.clone())
            return response
          })
        } else {
          return response
        }
      })
    })
  )
}

self.onactivate = event => {
  return event.waitUntil(
    caches.keys().then(keys => Promise.all(
      keys.map(key => {
        if (key == CACHE_NAME) {
          return caches.delete(key)
        } else {
          return Promise.resolve()
        }
      })
    ))
  )
}<commit_msg>Update Service Worker<commit_after>/**
 * sw.js
 */

let CACHE_NAME = 'yk-blog'

self.oninstall = event => {
  event.waitUntil(
    caches.open(CACHE_NAME).then(cache => cache.addAll([
      '/',
      '/assets/css/main.css',
      '/assets/js/func.js',
      '/assets/js/particles.js',
      '/assets/js/anchor.js'
    ]))
  )
}

self.onfetch = event => {
  event.respondWith(
    caches.match(event.request).then(response => {
      if (response && response.type == 'basic') {
        return response
      }
      return fetch(event.request).then(response => {
        if (response.ok && response.type == 'basic') {
          return caches.open(CACHE_NAME).then(cache => {
            cache.put(event.request, response.clone())
            return response
          })
        } else {
          return response
        }
      })
    })
  )
}

self.onactivate = event => {
  return event.waitUntil(
    caches.keys().then(keys => Promise.all(
      keys.map(key => {
        if (key == CACHE_NAME) {
          return caches.delete(key)
        } else {
          return Promise.resolve()
        }
      })
    ))
  )
}
{'fraction_non_alphanumeric': 0.16149347728295096, 'fraction_numerical': 0.0, 'mean_word_length': 1.8512820512820514, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3027739', 'n_tokens_mistral': 718, 'n_tokens_neox': 714, 'n_words': 109}