DotNetNuke Powered!
          
John Mitchell's (mostly DotNetNuke) Blog - Changing HttpCacheability to Speed up your DotNetNuke Site
 Tuesday, June 06, 2006

In the code-behind of the default page of DotNetNuke their is a setting that turns off client-side caching of the content.

Most websites allow their content to be cached on your machine so that it only has to be checked for an update the next time you access it.

For security reasons, DotNetNuke is set to tell your client machine (and proxy server if you have one) not to cache any content that it receives, so everytime you visit a page your browser will have to download all the images, etc. again.

This was done at a high level, and is probably overkill in most places within your portal. For example if you have a forums on your site, there is probably not any highly secure information that might be left on your machine if the browser is allowed to cache the content.

When you are logged in as admin, the control panel has several images, and so does the rich text editor when you are changing content.  You probably are not too worried that someone may get those images on their machine and be able to access them later.

So, for a quick fix and to give your web server a rest, you can place the following code into any skin that you would then apply to any page where you want to allow content to be cached by the people browsing your site.

<script runat="server">
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'HttpCacheability.Public allows all content to be cached by Proxy servers and client machines.
Page.Response.Cache.SetCacheability(HttpCacheability.Public)
End Sub
</script>

There are other settings for HttpCacheability which can be found at the following link:

http://msdn2.microsoft.com/en-us/library/system.web.httpcacheability(VS.80).aspx

A future version of DotNetNuke will probably allow this setting to be changed through the Admin UI, but until then, the above change is easy to make and does not affect the core.

**Update:  DotNetNuke now has the ability to set the HttpCacheability at the host level, but you still need something like this method to allow you to set the HttpCacheability at the Skin/Page level.

 

6/6/2006 3:18:45 PM (Central Daylight Time, UTC-05:00)  #    Comments [8]
7/3/2006 9:41:29 PM (Central Daylight Time, UTC-05:00)
Which versions of DNN will this apply to? Looks like I'll have to recompile to bring about the change you suggest - or was it mostly .NET 2 that you had in mind?
7/4/2006 7:33:04 AM (Central Daylight Time, UTC-05:00)
This will work on any version of DNN, and no re-compile is needed. Just place the above code in the .ascx version of your skin.
7/8/2006 11:39:46 AM (Central Daylight Time, UTC-05:00)
Dear John

OK, but do you have to upload your skin again(.zip file)? Or can you put this code just in the ascx file when it is already uploaded?...
7/8/2006 11:44:36 AM (Central Daylight Time, UTC-05:00)
It can go directly in the .ascx file or in the html version of the skin if you want to package it.
4/26/2008 2:04:27 PM (Central Daylight Time, UTC-05:00)
Soma order online
4/26/2008 6:10:51 PM (Central Daylight Time, UTC-05:00)
Buying brand paxil
4/26/2008 6:14:31 PM (Central Daylight Time, UTC-05:00)
cheapest acyclovir order online
5/13/2008 12:28:47 PM (Central Daylight Time, UTC-05:00)
I tried to implement the script but find that images are still not beeing cached.
Name
E-mail
Home page

Comment (HTML not allowed)  

Enter the code shown (prevents robots):