Template
mirror of
https://github.com/cotes2020/jekyll-theme-chirpy.git
synced 2026-09-20 12:22:57 +00:00
fix(pwa): bypass cache for third-party plugins (#2795)
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
---
|
||||
layout: compress
|
||||
swcache: true
|
||||
---
|
||||
|
||||
[
|
||||
|
||||
+65
-27
@@ -5,43 +5,81 @@ permalink: '/:path/swconf.js'
|
||||
---
|
||||
|
||||
const swconf = {
|
||||
{% if site.pwa.cache.enabled %}
|
||||
{%- if site.pwa.cache.enabled %}
|
||||
cacheName: 'chirpy-{{ "now" | date: "%s" }}',
|
||||
|
||||
{%- comment -%} Resources added to the cache during PWA installation. {%- endcomment -%}
|
||||
resources: [
|
||||
{%- comment -%} The specific list of URLs automatically cached during PWA installation. {% endcomment %}
|
||||
precacheUrls: [
|
||||
'{{ "/assets/css/:THEME.css" | replace: ':THEME', site.theme | relative_url }}',
|
||||
'{{ "/" | relative_url }}',
|
||||
{% for tab in site.tabs %}
|
||||
'{{- tab.url | relative_url -}}',
|
||||
{% for tab in site.tabs -%}
|
||||
'{{ tab.url | relative_url }}',
|
||||
{% endfor %}
|
||||
|
||||
{% assign cache_list = site.static_files | where: 'swcache', true %}
|
||||
{% for file in cache_list %}
|
||||
'{{ file.path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%}
|
||||
{% endfor %}
|
||||
{%- assign cache_list = site.static_files | where: 'precache', true -%}
|
||||
{% for file in cache_list -%}
|
||||
'{{- file.path | relative_url -}}'{%- unless forloop.last -%},{% endunless %}
|
||||
{% endfor -%}
|
||||
],
|
||||
|
||||
interceptor: {
|
||||
{%- comment -%} URLs containing the following paths will not be cached. {%- endcomment -%}
|
||||
paths: [
|
||||
{% for path in site.pwa.cache.deny_paths %}
|
||||
{% unless path == empty %}
|
||||
'{{ path | relative_url }}'{%- unless forloop.last -%},{%- endunless -%}
|
||||
{% endunless %}
|
||||
{% endfor %}
|
||||
],
|
||||
{%- comment -%} Define URLs that should be excluded from the cache. {%- endcomment -%}
|
||||
|
||||
{%- comment -%} URLs containing the following prefixes will not be cached. {%- endcomment -%}
|
||||
urlPrefixes: [
|
||||
{% if site.analytics.goatcounter.id != nil and site.pageviews.provider == 'goatcounter' %}
|
||||
'https://{{ site.analytics.goatcounter.id }}.goatcounter.com/counter/'
|
||||
{% endif %}
|
||||
]
|
||||
},
|
||||
{%- assign deny_urls = '' -%}
|
||||
|
||||
{%- if site.comments.provider -%}
|
||||
{%- case site.comments.provider -%}
|
||||
{%- when 'disqus' -%}
|
||||
{%- assign deny_urls = deny_urls | append: 'disqus\.com::' -%}
|
||||
{%- when 'utterances' -%}
|
||||
{%- assign deny_urls = deny_urls | append: 'utteranc\.es::' -%}
|
||||
{%- when 'giscus' -%}
|
||||
{%- assign deny_urls = deny_urls | append: 'giscus\.app::' -%}
|
||||
{%- endcase -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- comment -%} Analytics & Pageviews providers {% endcomment -%}
|
||||
|
||||
{%- if site.analytics.google.id -%}
|
||||
{%- assign deny_urls = deny_urls | append: 'googletagmanager\.com::' -%}
|
||||
{%- endif %}
|
||||
|
||||
{%- if site.analytics.goatcounter.id -%}
|
||||
{%- assign deny_urls = deny_urls | append: '\.zgo\.at::' -%}
|
||||
{%- endif %}
|
||||
|
||||
{%- if site.analytics.cloudflare.id -%}
|
||||
{%- assign deny_urls = deny_urls | append: '\.cloudflareinsights\.com::' -%}
|
||||
{%- endif %}
|
||||
|
||||
{%- if site.analytics.fathom.id -%}
|
||||
{%- assign deny_urls = deny_urls | append: '\.usefathom\.com::' -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if site.analytics.umami.id and site.analytics.umami.domain -%}
|
||||
{%- assign umami_domain = site.analytics.umami.domain | replace: '.', '\.' -%}
|
||||
{%- assign deny_urls = deny_urls | append: umami_domain | append: '::' -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if site.analytics.matomo.id and site.analytics.matomo.domain -%}
|
||||
{%- assign matomo_domain = site.analytics.matomo.domain | replace: '.', '\.' -%}
|
||||
{%- assign deny_urls = deny_urls | append: matomo_domain | append: '::' -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- if site.pageviews.provider -%}
|
||||
{%- case site.pageviews.provider -%}
|
||||
{%- when 'goatcounter' -%}
|
||||
{%- assign deny_urls = deny_urls | append: '\.goatcounter\.com::' -%}
|
||||
{%- endcase -%}
|
||||
{%- endif -%}
|
||||
|
||||
{%- for path in site.pwa.cache.deny_paths -%}
|
||||
{%- assign url = path | absolute_url | replace: '.', '\.' | replace: '/', '\/' -%}
|
||||
{%- assign deny_urls = deny_urls | append: url | append: '::' -%}
|
||||
{%- endfor %}
|
||||
|
||||
denyUrls: {{ deny_urls | split: '::' | jsonify }},
|
||||
purge: false
|
||||
{% else %}
|
||||
{%- else %}
|
||||
purge: true
|
||||
{% endif %}
|
||||
{%- endif %}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user