Serving static assets with an efficient cache policy on azure app

Simon Lovejoy 0 Reputation points
2024-06-23T07:02:42.52+00:00

I am attempting to set up long-life caching on my azure app based on the following recommendation:

'A long cache lifetime improves repeat visits to pages on a subdomain.

Configure your server to return the Cache-Control HTTP response header:

Cache-Control: max-age=31536000

Cache static assets for a year or longer where possible'

Is there functionality within the app portal allowing users to achieve this?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,913 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sreeju Nair 12,366 Reputation points
    2024-06-23T09:38:53.7333333+00:00

    To implement caching in Azure App Service, you need to configure the Cache-Control header specific to the technology stack of your application.

    For ASP.Net applications, this can be done in the web.config file, for PHP applications , it can be set in the htaccess file and for Node.js applications, you can use middleware to set the header.

    Each technology has its own method for configuring these headers, so refer to the relevant documentation for your specific stack to set the Cache-Control header to max-age=31536000 for caching static assets effectively.

    It is interesting to note that Azure App Service support Local Cache in many scenarios, that can be enabled by you to improve the performance. Refer: https://learn.microsoft.com/en-us/azure/app-service/overview-local-cache

    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.