Friday, January 15, 2016

How to CACHE using .NET

Add <?xml .... >  script below to the directory you want to CACHE for 365 days - if it is static than why have the client retrieve it, over and over again --- BAD HIT ON SPEED OF SITE.  Note for CSS and Scripts it is best practice to have a version number on the file and update the reference.


<link rel="stylesheet" type="text/css" href="/framework/css/global.min.css?v=2.0" media="screen, print" />

<?xml version="1.0" encoding="UTF-8"?>
            <clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="365.00:00:00" />

Always add ?v=x.x and increment when you make changes to the css or js files.  If not end-users will get older versions of your CSS or JS and will cause a nightmare and lose potential customers or clients.