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

Fails to load newly added samples from GitHub (due to cached strudel.json) #1218

Open
nkymut opened this issue Nov 21, 2024 · 0 comments
Open

Comments

@nkymut
Copy link

nkymut commented Nov 21, 2024

Strudel is not able to load newly added samples using GitHub shortcut.
It appear to be loading the sample from the cached strudel.json file even after the file is updated on the server.
This results in errors when trying to load the new samples.

On a computer, users can hard-refresh the cache by pressing Command+Shift+R (macOS) or Ctrl+Shift+R (Windows/Linux). However, clearing the cache on mobile devices is less intuitive and often requires navigating to browser settings to clear the cache.

Steps to Reproduce

  1. Create a pattern to load a sample using the GitHub shortcut.
  2. Add new sample audio files to the GitHub repository and update the "strudel.json" file to include references to the new files.
  3. Update the pattern in Strudel to load the newly added sample.
  4. following error in the console:
    [cyclist] error: sound {newsoundname} not found! Is it loaded?
  5. On a computer, har-refreshing the browser will load the sample

Potential Solution

The issue appears to stem from the current caching strategy in Astro, which uses a CacheFirst approach for external resources. Switching the caching strategy to StaleWhileRevalidate for strudel.json could resolve the issue.

Proposed Change:

Update the AstroPWA configuration as follows:

AstroPWA({
      experimental: { directoryAndTrailingSlashHandler: true },
      registerType: 'autoUpdate',
      injectRegister: 'auto',
      workbox: {
        globPatterns: ['**/*.{js,css,html,ico,png,svg,json,wav,mp3,ogg,ttf,woff2,TTF,otf}'],
        runtimeCaching: [
          {
            urlPattern: ({ url }) =>
              [
                /^https:\/\/raw\.githubusercontent\.com\/.*/i,
                /^https:\/\/freesound\.org\/.*/i,
                /^https:\/\/cdn\.freesound\.org\/.*/i,
                /^https:\/\/shabda\.ndre\.gr\/.*/i,
              ].some((regex) => regex.test(url)),
            handler: 'StaleWhileRevalidate', // changed  from "CacheFirst"
            options: {
              cacheName: 'external-samples',
              expiration: {
                maxEntries: 5000,
                maxAgeSeconds: 60 * 60 * 24 * 30, // <== 14 days
              },
              cacheableResponse: {
                statuses: [0, 200],
              },
            },
          },
        ],
      },
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant