Enable browser caching of static assets

Newbie question here.

I’ve been searching round the internet on this one to understand what browser caching of static assets means as my site fails entirely.

As far as I can tell this involves setting the headers transmitted alongside (say) an image file by the site’ server.

I have a fairly basic hosting plan serving .asp pages with iis. [size=x-small](I’m eventually going to rebuild the site using .php & apache, but that is another issue).[/size] Does this kind of hosting plan usually allow you to configure the caching headers? I’ve seen how to configure .php or .asp page headers, but not .gif or .jpg for instance. It looks like I need to confire iis which my host plan wouldn’t let me do. (If you think it is likely that I can configure this, can anyone recommend a link with more info about how to do it?)

If I cannot do this. Does Serving static content from a cookieless domain basically have the same effect?

I could move my images to a linux server where I could change my .htaccess file. It looks easy to set up cache control there.

Do you think that is my best option? (I could kill 2 birds with one stone). Would I get a substantial increase in performance?

Here are my results (don’t know how long you keep them for)

Thanks for your help.

The results are kept for ever (at least so far they have been)…

I’d be REALLY surprised if the asp hosting provider didn’t let you adjust the expires times for the various mime types and directories but it would probably have to be done through their UI. Same goes for the gzip compression which is pretty critical to get done.

You do have to be careful when you enable caching and make sure you change the names of the files (or query stringg) to make sure when you update something like the logo that people will see the new one and not whatever is in their cache.

There are a few other changes that you can make that will make the site a LOT faster even for a first-time visitor:

  • Merge the 4 css files into a single file and the 2 js files into a single one. That will save about 1/2 a second off of the time but more importantly, will take it off of the “start render” time.

  • Use image sprites for the images in the “graficos” directory. Google for “spriteme” which can help get it done. That will combine a bunch of the images into a single request. That will save another 2-3 seconds off of the load time.

Thanks for your very informative reply.

It is a very basic shared windows hosting plan. They don’t seem to give you that kind of level of access to the server configuration. I don’t blame them… you know what windows is like.

However, if I put my images onto another domain hosted by linux, it looks easy to configure the cache settings with .htaccess. (I have a few spare domains available at the moment) I think it would be less work than trying to work out if it is possible to configure iis - and at the same time would have the advantage of being cookie free & also make the site more portable for when I eventually rewrite in php.

Thanks for the warning. I’d already figured I’d need to do that when necessary.

I’m reluctant to do this with the css for several reasons. One is that I use conditional comments to give IE different css. Also I have one universal sheet for the whole site & then a couple of other sheets that only apply to certain pages. I figured it would be slower on the 1st page that the user loads & then not much different. On the site in general most browsers will only get 1 or 2 style sheets. Perhaps I should do a special sheet for the home page only.

That spriteme is amazing! I can’t believe what it does! I knew it was possible to do that kind of thing, but couldn’t bear the idea of trying to do it by hand. I just wonder about IE compatibility. I need to investigate.

It would obviously make a huge difference.

I will recommend that you should move your images to Apache server and configure proper cache time.

You can also use simplecdn.com services (its cheap) which will resolve your issues of cache and cookie less domain easily. You won’t have to maintain another hosting account on Apache and keep uploading new images to apache. This will also provide Gzip for css files.

Serving static content from separate domain dose not only save on cookies it also provides parallel connection for downloading.

Hey there,

I use to have all of my images under one domain. I read somewhere that most browsers only have two connections by default, which means only two images can download before another two start.

Recently, I setup a few subdomains on my server.


I know my images can be downloaded in parallel now, which makes it seem like a webpage loads faster. I think that this might take care of serving it from a cookieless domain issue as well?

Travis Walters

Only if the cookies are not set to the .mydomain.com level but it certainly makes it possible :slight_smile:

btw, the number of connections is kind of old information. All of the “modern” browsers use 6+ connections per domain (IE8, FFX 3.5+, Chrome, Safari) but it’s worth keeping in mind since the older browsers are still a majority of the market in a lot of cases.

I tried applying the suggestion and its working very fine for me.
Call for paper - optimized
Webpage test provide very gud analysis