Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Caching CSS and html files by the client browser View modes: 
User avatar
Member
Member
Stratego - 5/22/2011 7:23:15 PM
   
Caching CSS and html files by the client browser
Using the Net tab in Firebug running on Firefox 3.6 I can see that when I visit my site, the second time a page is loaded the html and CSS files are not cached by the browser but are reloaded.

When I visit other pages in the site all images also used by other previously visited pages are cached as are all js files.

In fact as I navigate around, the only items that are not cached are the Google Analytics gif and the CSS and the html.

I read in the documentation that I can get the browser to cache the CSS by "adding the following key into the configuration/appSettings section of your web.config: <add key="CMSFullClientCache" value="true"/>"

However, I could not understand what is meant by "This type of caching can be useful only for live site displaying, as changes made to the page in non-live-site modes would not be displayed due to the caching." as I don't know what is a "non-live-site mode".

Is it advisable to use the CMSFullClientCache setting to improve performance by not reloading the CSS for every page?

Also is it not at all possible for the browser to cache the html on return visits to a page? It seems to me that the html is identical on a return visit to a page within a short period of time.

Thank you

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 5/23/2011 2:58:24 AM
   
RE:Caching CSS and html files by the client browser
Hello,

You can setup full page caching without adding the web.config key. This can be done in CMS Desk -> Content -> Properties -> General -> Cache. The key you are mentioning should do the same without the mentioned settings. The "non-live-site mode" is every other mode than the live site such as the Preview mode in CMSDesk. The mentioned setting and key should enable you to cache also the html output. You can also find useful information on boosting the performance of your Kentico site on the following blog.

Best regards,
Boris Pocatko

User avatar
Member
Member
Stratego - 5/27/2011 4:19:39 AM
   
RE:Caching CSS and html files by the client browser
Thank you for the reply Boris.

I had already read that blog and all the Kentico documentation.

The site is on Kentico CMS 5.5 R2.

I already had full page caching set to 60 mins using CMS Desk -> Content -> Properties -> General -> Cache.

I also already had CMS Site Manager -> Settings at a Global level with inheritance in the web site
- Cache content = 60 mins
- Cache images = 60 mins
- Cache page info = 60 mins

and had the radio buttons checked in Site Manager -> Settings -> Files
for the three check boxes Store files in file system, Store files in database and Generate thumbnails.

Despite all those settings, according to Firebug every time I request a page the html and CSS files get reloaded.

As an experiment I put all the above settings back to empty and got exactly the same result.
(Tomorrow I will check using Site24x7.com as to whether the site is running slower as a result.)

I am certain that all the caching settings make no difference as to whether the HTML and CSS files are read from cache.
No matter whether I have cache settings or not, these two files are reloaded each
time and never come from cache. And no matter whether I have cache settings or
not, all other files requests except Google Analytics come from cache after the first
page load.



This is the header with all caching turned off….

Cache-Control private, no-store, must-revalidate
Content-Type text/html; charset=utf-8
Server Microsoft-IIS/7.0
X-AspNet-Version 4.0.30319
X-Powered-By ASP.NET
Date Fri, 27 May 2011 08:27:43 GMT
Content-Length 22216
Request Headersview source
Host www.sinclairblack.co.nz
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17 ( .NET CLR 3.5.30729; .NET4.0E)
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Referer http://www.sinclairblack.co.nz/Home
Cookie CMSPreferredCulture=en-NZ; CMSPreferredUICulture=en-nz; __utma=102601219.2040435124.1305774152.1306481866.1306484598.15; __utmz=102601219.1306112822.8.5.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=media%20law%20auckland; VisitorStatus=2; ViewMode=0; PropertyTab=0; ASP.NET_SessionId=4gfz4vmgijxlqxbwfvslrwqm; CurrentVisitStatus=2; CurrentTheme=SinclairBlackV3CrossV2; __utmc=102601219; .ASPXFORMSAUTH=DC12FC3E8B65F06BC88D987830E399DC97DF2DC6DB9767BE3BA4DBB84DC6E9EEE67676E01E747BCDA5716E048C6C3F10666D166402D9028F61BA3A5D4368C71DC4F1AC58D48AC458F2BD92C4F00B0F9E2A35F1127D5B719846777A454703FCEA; __utmb=102601219.9.10.1306484598
DNT 1
Connection keep-alive



This is the header with caching set at 60 mins in CMS > Content > Properties >
General at the master page level with inheritance at the Home page level (and all the other cache settings empty) …….

Cache-Control private, no-store, must-revalidate
Content-Type text/html; charset=utf-8
Server Microsoft-IIS/7.0
X-AspNet-Version 4.0.30319
X-Powered-By ASP.NET
Date Fri, 27 May 2011 08:33:44 GMT
Content-Length 22216
Request Headersview source
Host www.sinclairblack.co.nz
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17 ( .NET CLR 3.5.30729; .NET4.0E)
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Referer http://www.sinclairblack.co.nz/Home.aspx
Cookie CMSPreferredCulture=en-NZ; CMSPreferredUICulture=en-nz; __utma=102601219.2040435124.1305774152.1306481866.1306484598.15; __utmz=102601219.1306112822.8.5.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=media%20law%20auckland; VisitorStatus=2; ViewMode=0; PropertyTab=0; ASP.NET_SessionId=4gfz4vmgijxlqxbwfvslrwqm; CurrentVisitStatus=2; CurrentTheme=SinclairBlackV3CrossV2; __utmc=102601219; .ASPXFORMSAUTH=DC12FC3E8B65F06BC88D987830E399DC97DF2DC6DB9767BE3BA4DBB84DC6E9EEE67676E01E747BCDA5716E048C6C3F10666D166402D9028F61BA3A5D4368C71DC4F1AC58D48AC458F2BD92C4F00B0F9E2A35F1127D5B719846777A454703FCEA; __utmb=102601219.13.10.1306484598
DNT 1
Connection keep-alive



This is the header with caching set at 60 mins in CMS > Content > Properties >
General at the Home page level (and all the other cache settings empty) …….

Cache-Control no-cache, must-revalidate
Pragma no-cache
Expires -1
Server Microsoft-IIS/7.0
X-Powered-By ASP.NET
Date Fri, 27 May 2011 08:43:49 GMT
Content-Length 22216
X-Antivirus avast! 4
X-Antivirus-Status Clean
Request Headersview source
Host www.sinclairblack.co.nz
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17 ( .NET CLR 3.5.30729; .NET4.0E)
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language en-us,en;q=0.5
Accept-Encoding gzip,deflate
Accept-Charset ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive 115
Referer http://www.sinclairblack.co.nz/Home
Cookie CMSPreferredCulture=en-NZ; CMSPreferredUICulture=en-nz; __utma=102601219.2040435124.1305774152.1306481866.1306484598.15; __utmz=102601219.1306112822.8.5.utmcsr=google|utmccn=(organic)|utmcmd=organic|utmctr=media%20law%20auckland; VisitorStatus=2; ViewMode=0; PropertyTab=0; ASP.NET_SessionId=4gfz4vmgijxlqxbwfvslrwqm; CurrentVisitStatus=2; CurrentTheme=SinclairBlackV3CrossV2; __utmc=102601219; .ASPXFORMSAUTH=DC12FC3E8B65F06BC88D987830E399DC97DF2DC6DB9767BE3BA4DBB84DC6E9EEE67676E01E747BCDA5716E048C6C3F10666D166402D9028F61BA3A5D4368C71DC4F1AC58D48AC458F2BD92C4F00B0F9E2A35F1127D5B719846777A454703FCEA; __utmb=102601219.15.10.1306484598
DNT 1
Connection keep-alive



Web.config has these appSettings….
<appSettings>
<add key="CMSProgrammingLanguage" value="C#" />
<add key="WS.webservice" value="http://localhost/WebService/webservice.asmx" />
<add key="CMSTrialKey" value="CU05-20110507-fCbv8J" />
<add key="CMSDebugCache" value="true"/>

<add key="CMSDebugCacheLive" value="true"/>

<add key="CMSDebugCacheLogLength" value="10"/>

<add key="CMSLogCache" value="true" />

<!-- <add key="CMSFullClientCache" value="true"/> -->

</appSettings>

The behaviour reported by Firebug is no different with or without the CMSFullClientCache entry.



It seems to me that setting the caching has the advantage that the page is not
regenerated by the server within the defined cache period (and is instead served
from the server cache) but it makes no difference as to whether the browser
reloads the HTML and CSS from the server or its local cache. These two files have
never been retrieved from the local cache for me in the testing I have done -
according to Firebug.


Thank you once again

User avatar
Member
Member
Stratego - 5/27/2011 6:05:02 PM
   
RE:Caching CSS and html files by the client browser
Sorry, this is a correction to my post above.

I thought that I had CMS Site Manager -> Settings at a Global level with inheritance in the web site
- Cache content = 60 mins
- Cache images = 60 mins
- Cache page info = 60 mins

In fact I didn't have the inheritance boxes ticked. (Shouldn't work so late.)

I ticked them and now the CSS is being read from the browser cache subsequent to a 304 Not Modified being returned.

So now it is only the HTML that is not read from the browser cache.

I have reverted to having all possible server caching activated except for the appSettings key CMSFullClientCache in the web.config file.

The headers and cache details revealed by Firebug are as follow;

CSS

These are the CSS Cache details from Firebug……

Last Modified Sat May 28 2011 10:00:07 GMT+1200 (New Zealand Standard Time)
Last Fetched Sat May 28 2011 10:00:07 GMT+1200 (New Zealand Standard Time
Expires Thu Jan 01 1970 13:00:00 GMT+1300 (New Zealand Daylight Time
Data Size 24595
Fetch Count 33
Device disk

These are the abbreviated CSS Headers details from Firebug…….

Cache-Control public, must-revalidate
Content-Type text/html
Etag "c1cd7432-69a5-4bcc-b2b8-774824adfabc"
Server Microsoft-IIS/7.0
X-AspNet-Version 4.0.30319
X-Powered-By ASP.NET
Date Fri, 27 May 2011 21:59:13 GMT

Request Headers view source
Keep-Alive 115
Referer http://www.sinclairblack.co.nz/Home
DNT 1
Connection keep-alive
If-Modified-Since Fri, 27 May 2011 21:53:25 GMT
If-None-Match "c1cd7432-69a5-4bcc-b2b8-774824adfabc"



HTML

This is the Response Header for the HTML…

Cache-Control no-cache, must-revalidate
Pragma no-cache
Expires -1
Server Microsoft-IIS/7.0
X-Powered-By ASP.NET
Date Fri, 27 May 2011 21:59:13 GMT
Content-Length 31523

And the HTML Cache Details

Last Modified Sat May 28 2011 10:00:07 GMT+1200 (New Zealand Standard Time)
Last Fetched Sat May 28 2011 10:00:07 GMT+1200 (New Zealand Standard Time)
Expires Thu Jan 01 1970 13:00:00 GMT+1300 (New Zealand Daylight Time)
Data Size 31523
Fetch Count 16
Device disk

HTML Request Header……

Keep-Alive 115
Referer http://www.sinclairblack.co.nz/Home
DNT 1
Connection keep-alive


In summary;

1)
Full page caching set to 60 mins using CMS Desk -> Content -> Properties -> General -> Cache made no difference to client caching of CSS and HTML.

2)
CMS Site Manager -> Settings at a Global level with inheritance in the web site
- Cache content = 60 mins
- Cache images = 60 mins
- Cache page info = 60 mins
did make a difference to client caching as it caused the CSS to be cached but with a 304 Not Modified.

I am going not try any more to get the HTML to cache but would be interested to know if this is working as designed?

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 5/30/2011 6:27:33 AM
   
RE:Caching CSS and html files by the client browser
Hello,

I've checked with our CTO and this is currently the standard behavior. You can try to enable the output caching as described here. The client side caching of html should be available from the 6.0 version of Kentico.

If you want to change the response, you can do that programmatically in the Application_BeginRequest method in the Global.asax.cs file.

Best regards,
Boris Pocatko

User avatar
Member
Member
Stratego - 6/2/2011 2:06:45 PM
   
RE:Caching CSS and html files by the client browser
Thank you very much Boris.

Looking forward to 6.0 but not a problem if control of client site caching is not in it. I don't have a site speed problem - was just looking for perfection.

Enjoy your weekend.

User avatar
Kentico Consulting
Kentico Consulting
kentico_borisp - 6/2/2011 10:46:29 PM
   
RE:Caching CSS and html files by the client browser
Hello,

Hopefully, it will be there. I think some of our clients would appreciate it anyway. Have a wonderful weekend yourself!

Best regards,
Boris Pocatko