0

I want to cache image & JS files on a static webpage. and trying to improve browser cache score, after adding following tag it doesn't make any difference to the cache score which remains at 49.

Will adding meta http-equiv="cache-control" adding caching for all elements on page or not

enter image description here

<meta http-equiv="cache-control" content="max-age=864000" />

Is there a simple way of adding cache property to images and JS files

<script src='<%= ResolveUrl ("~/assets/js/main.js?v=1.0.9x") %>'></script>

<img src="../images/logo.png"/>

Webpage are hosted on windows server so .htaccess is not supported how can we configure same in windows hosted environment with .htaccess it was easy as i had to add only following code to file

## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##
1

To leverage Browser Caching on Windows Host, assuming it's IIS, you have to add this snippet in the web.config file in the document root of your website:

<system.webServer>
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="30.00:00:00" />
</staticContent>
</system.webServer>

The cacheControlMaxAge setting will tell how much time all static ressources should be cached, here it is set to 30 days.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.