Static web App caching content

Vipal Mehta 45 Reputation points
2024-01-02T08:12:35.7+00:00

We are using Standard Hosting plan on Static Web Apps in our organization. Deployment is done through Azure Devops.

We are often experiencing caching issues in Static Web App, where we see older code content, even on a machine where we visit the site for the first time and no browser cache is stored.

To handle browser cache as per below article, we have already modified the staticwebapp.json as below, still no luck. -

{
    "navigationFallback": {
      "rewrite": "/index.html"
    },
    "headers": {
      "Referrer-Policy": "strict-origin-when-cross-origin"
    },
    "globalHeaders": {
      "Cache-Control": "no-cache, no-store"
  }
}

https://learn.microsoft.com/en-us/answers/questions/820088/azure-static-web-app-old-cached-version-still-show

Request assistance or provide a way to purge the cache in Azure Static Web App or suggest some solutions to this issue which we are observing.

Thanks,

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
1,173 questions
{count} vote

2 answers

Sort by: Most helpful
  1. brtrach-MSFT 17,731 Reputation points Microsoft Employee Moderator
    2024-01-03T00:23:19.7766667+00:00

    @Vipal Mehta It seems like you’re experiencing caching issues with Azure Static Web Apps, even after modifying the staticwebapp.json file. This can indeed be a tricky issue to debug. Here are a few suggestions:

    1. Check the Deployment Process: Ensure that the deployment process is working correctly, and that the new version of your app is being deployed as expected.
    2. Inspect Network Traffic: Use the network tab in the browser’s developer tools to inspect the network traffic when loading your app. Check the HTTP headers of the responses to ensure that they include the correct Cache-Control header.
    3. Test on Different Browsers and Devices: Try accessing your app from different browsers and devices to see if the issue persists.

    Let us know the outcome of the above steps.

    1 person found this answer helpful.
    0 comments No comments

  2. Luis Arias 8,621 Reputation points Volunteer Moderator
    2024-01-02T09:25:34.0533333+00:00

    Hi Vipal Mehta,

    Here a few suggestions that might help:

    1. Confirm Folder Configuration to know which folders to use to host your application. This configuration is confirmed by the build process at the end of the workflow. Any errors are logged during the validation steps (https://learn.microsoft.com/en-us/azure/static-web-apps/troubleshooting).
    2. Aggressive Caching: You could try uploading all files with aggressive caching (6 months), then change the caching of landing pages to something less aggressive or remove caching entirely (https://blog.bredvid.no/improving-azure-static-web-site-performance-b949b32233e2).

    Remember, the staticwebapp.config.json file controls settings like Routing, Authentication, Authorization, Fallback rules, HTTP response overrides, Global HTTP header definitions, Custom MIME types, and Networking (source).

    Let me know if this help you,

    Luis


    If the information helped address your question, please Accept the answer.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.