Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid caching pageviews data #1849

Merged
merged 3 commits into from
Jul 17, 2024

Conversation

kungfux
Copy link
Collaborator

@kungfux kungfux commented Jul 9, 2024

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Description

To retrieve pageviews we send GET request from _includes/pageviews/goatcounter.html. When PWA is enabled, the response is cached and so the pageview counter is not updated as expected.

Additional context

I see two possible ways to fix this behavior:

  1. Make GET requests unique
  2. Avoid caching these requests

Option 1 is easy fix, applied in this PR but has it's drawbacks e.g. utilize cache.

Option 2 seems preferable. However, it requires changes in _javascript/pwa/sw.js to support non-relative paths.
Please let me know your thoughts on this.

@kungfux kungfux marked this pull request as ready for review July 9, 2024 18:38
Copy link
Owner

@cotes2020 cotes2020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous solution (before 8362564) was to filter GA URLs by configuration file data/swcache.js.

/* Requests that include the following path will be banned */
const denyUrls = [
{% if site.google_analytics.pv.cache_path %}
'{{ site.google_analytics.pv.cache_path | absolute_url }}'
{% endif %}
];

Now we can restore this configuration in assets/js/data/swconf.js

@kungfux kungfux force-pushed the bugfix/prevent-pageviews-caching branch from f8129fb to 3d501cc Compare July 9, 2024 19:46
@kungfux
Copy link
Collaborator Author

kungfux commented Jul 9, 2024

I forgot that we used to have pageviews. Thanks for reminding me.

I have published changes as suggested. Please let me know what do you think.

Copy link
Owner

@cotes2020 cotes2020 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Defining in denyPaths doesn't seem to fit because it sets relative paths.

We should define a new variable denyUrls to store these CORS URLs.

Also, _javascript/pwa/sw.js needs to be modified accordingly.

@kungfux kungfux marked this pull request as draft July 10, 2024 20:29
@kungfux kungfux force-pushed the bugfix/prevent-pageviews-caching branch 4 times, most recently from 455b05f to 0b1f717 Compare July 11, 2024 22:40
@kungfux kungfux marked this pull request as ready for review July 11, 2024 22:44
_config.yml Outdated Show resolved Hide resolved
assets/js/data/swconf.js Outdated Show resolved Hide resolved
@kungfux kungfux force-pushed the bugfix/prevent-pageviews-caching branch from 0b1f717 to 5911624 Compare July 17, 2024 04:25
@cotes2020 cotes2020 merged commit 979f86c into cotes2020:master Jul 17, 2024
7 checks passed
@cotes2020 cotes2020 changed the title bugfix: prevent pageview requests caching Avoid caching pageviews data Jul 17, 2024
@kungfux kungfux deleted the bugfix/prevent-pageviews-caching branch July 17, 2024 17:21
gudtldn pushed a commit to gudtldn/gudtldn.github.io that referenced this pull request Jul 26, 2024
github-actions bot pushed a commit that referenced this pull request Aug 27, 2024
## [7.1.0](v7.0.1...v7.1.0) (2024-08-27)

### Features

* add Bluesky social links ([#1759](#1759)) ([0102aba](0102aba))
* add Reddit social option ([#1836](#1836)) ([8673e13](8673e13))
* add Threads social links ([#1837](#1837)) ([e3a78b6](e3a78b6))
* **analytics:** add fathom analytics ([#1913](#1913)) ([befc4ce](befc4ce))
* **dev:** add vscode tasks ([#1843](#1843)) ([e4db1a1](e4db1a1))
* **dev:** support vscode dev-container ([#1781](#1781)) ([1e3d4a6](1e3d4a6))
* **ui:** improve block quote layout ([80bd792](80bd792))
* **ui:** improve visibility of inline code ([#1831](#1831)) ([c876731](c876731))
* **ui:** make `info-prompt` icon looks like the letter "i" ([#1835](#1835)) ([a07a57e](a07a57e))
* **ui:** set `<kbd>` font to 'Lato' ([64c7262](64c7262))

### Bug Fixes

* adapt the giscus localization parameter ([#1810](#1810)) ([0709854](0709854))
* avoid caching pageviews data ([#1849](#1849)) ([979f86c](979f86c))
* remove extra dual-mode images from lightbox ([#1883](#1883)) ([5c5910f](5c5910f))
Copy link

🎉 This issue has been resolved in version 7.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

ryo-wijaya pushed a commit to ryo-wijaya/blog that referenced this pull request Sep 9, 2024
## [7.1.0](cotes2020/jekyll-theme-chirpy@v7.0.1...v7.1.0) (2024-08-27)

### Features

* add Bluesky social links ([#1759](cotes2020/jekyll-theme-chirpy#1759)) ([6c7d07b](cotes2020/jekyll-theme-chirpy@6c7d07b))
* add Reddit social option ([#1836](cotes2020/jekyll-theme-chirpy#1836)) ([9711f2a](cotes2020/jekyll-theme-chirpy@9711f2a))
* add Threads social links ([#1837](cotes2020/jekyll-theme-chirpy#1837)) ([5e92fea](cotes2020/jekyll-theme-chirpy@5e92fea))
* **analytics:** add fathom analytics ([#1913](cotes2020/jekyll-theme-chirpy#1913)) ([78eda9d](cotes2020/jekyll-theme-chirpy@78eda9d))
* **dev:** add vscode tasks ([#1843](cotes2020/jekyll-theme-chirpy#1843)) ([0a92a68](cotes2020/jekyll-theme-chirpy@0a92a68))
* **dev:** support vscode dev-container ([#1781](cotes2020/jekyll-theme-chirpy#1781)) ([231e700](cotes2020/jekyll-theme-chirpy@231e700))
* **ui:** improve block quote layout ([2f84ff4](cotes2020/jekyll-theme-chirpy@2f84ff4))
* **ui:** improve visibility of inline code ([#1831](cotes2020/jekyll-theme-chirpy#1831)) ([2e81f62](cotes2020/jekyll-theme-chirpy@2e81f62))
* **ui:** make `info-prompt` icon looks like the letter "i" ([#1835](cotes2020/jekyll-theme-chirpy#1835)) ([68ce89d](cotes2020/jekyll-theme-chirpy@68ce89d))
* **ui:** set `<kbd>` font to 'Lato' ([e959570](cotes2020/jekyll-theme-chirpy@e959570))

### Bug Fixes

* adapt the giscus localization parameter ([#1810](cotes2020/jekyll-theme-chirpy#1810)) ([d420c8c](cotes2020/jekyll-theme-chirpy@d420c8c))
* avoid caching pageviews data ([#1849](cotes2020/jekyll-theme-chirpy#1849)) ([a69cf87](cotes2020/jekyll-theme-chirpy@a69cf87))
* remove extra dual-mode images from lightbox ([#1883](cotes2020/jekyll-theme-chirpy#1883)) ([338f926](cotes2020/jekyll-theme-chirpy@338f926))
RoboMico pushed a commit to RoboMico/robomico.cn that referenced this pull request Sep 22, 2024
RoboMico pushed a commit to RoboMico/robomico.cn that referenced this pull request Sep 22, 2024
## [7.1.0](cotes2020/jekyll-theme-chirpy@v7.0.1...v7.1.0) (2024-08-27)

### Features

* add Bluesky social links ([cotes2020#1759](cotes2020#1759)) ([0102aba](cotes2020@0102aba))
* add Reddit social option ([cotes2020#1836](cotes2020#1836)) ([8673e13](cotes2020@8673e13))
* add Threads social links ([cotes2020#1837](cotes2020#1837)) ([e3a78b6](cotes2020@e3a78b6))
* **analytics:** add fathom analytics ([cotes2020#1913](cotes2020#1913)) ([befc4ce](cotes2020@befc4ce))
* **dev:** add vscode tasks ([cotes2020#1843](cotes2020#1843)) ([e4db1a1](cotes2020@e4db1a1))
* **dev:** support vscode dev-container ([cotes2020#1781](cotes2020#1781)) ([1e3d4a6](cotes2020@1e3d4a6))
* **ui:** improve block quote layout ([80bd792](cotes2020@80bd792))
* **ui:** improve visibility of inline code ([cotes2020#1831](cotes2020#1831)) ([c876731](cotes2020@c876731))
* **ui:** make `info-prompt` icon looks like the letter "i" ([cotes2020#1835](cotes2020#1835)) ([a07a57e](cotes2020@a07a57e))
* **ui:** set `<kbd>` font to 'Lato' ([64c7262](cotes2020@64c7262))

### Bug Fixes

* adapt the giscus localization parameter ([cotes2020#1810](cotes2020#1810)) ([0709854](cotes2020@0709854))
* avoid caching pageviews data ([cotes2020#1849](cotes2020#1849)) ([979f86c](cotes2020@979f86c))
* remove extra dual-mode images from lightbox ([cotes2020#1883](cotes2020#1883)) ([5c5910f](cotes2020@5c5910f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants