HTML caching hardly anyone seems to do it right.

Started by Lazybones, May 10, 2013, 09:07:28 AM

Previous topic - Next topic

Lazybones

In addition to intranet web apps I am somewhat involved in our public website which has made me keenly aware of caching and how hardly any business apps make use of it and how well big sites do.

So I have a question to the web developers here, how much time do you put into optimizing caching?

One intranet app we have displays the user name at the top of every page and thus has the content set to private, but is also has the no-cache and max=0 flags set.

This effectively makes the HTML avoid all cache. Sure it is dynamic content however with cache fully disabled this also prevents the back button from pulling cached content. So as users read the root news page , jump to a content page and then back to root it performs both http lookups and backed database calls. A little testing has  shown that enabling te browser to cache even for 30s or 1min causes net instant back button functionality. Now you have to be careful not to use this on an edit screen/form but on content consumption pages this could be a huge gain in both user experience and server scalability / load.

It's a bit risky but I have been experimenting with altering the headers of some existing apps via a reverse proxy, with some interesting results.

Mr. Analog

We have a custom built resource cache that I *think* is set to expire every 24 hours (don't quote me on that, we don't manage prod configs), in our case resources are images and static files like help pages.

Otherwise we use AppFabric caching for service method calls, page content is all dynamic and will change based on your locale settings.

For scripts we use Combres, which automatically combines, minifies and compresses our CSS and JS resources. I believe we have this configured to utilize server-side caching as well.

I'm not certain if this is an optimal caching arrangement because I haven't seen any load tests that specifically target the site guts. (We run JMeter scripts and test our service performance directly from what I understand).

So far I'm very happy with Combres, it's the best at what it does. I think AppFabric is a step above MemCache but I'm not entirely sure we are using it correctly so I can't really say for sure whether or not it's better than other object caches out there.
By Grabthar's Hammer

Lazybones

#2
Yes, there are many levels you could cache at. Sounds like you are using some great application level tools.

I have been surprised by some of the apps that don't seem to do any caching at all other than static images.

When you break down page loads with firebug or pagespeed it can be quite interesting to see what you are waiting for.

Also interesting is the response time for some servers. Even with caching enabled in IIS my nginx reverse proxy delivers a cached image or cs file in 10-20ms vs 60-30s 60-300ms for the iis server alone.

Mr. Analog

30 to 60 seconds! Holy moley!

We try to operate on the 3 seconds or less rule, mind you I think we need to do some pruning on the client side, we have a lot of libraries like JQuery and Twitter Bootstrap and now we're using Font Awesome, I know the graphics they use in those libraries are fairly small but still, it adds up over time.

It has to be said, we have a fairly minimalist design ethos so likely we're not pushing that much stuff out to begin with that isn't unique or cached data.
By Grabthar's Hammer

Lazybones

Quote from: Mr. Analog on May 10, 2013, 10:21:44 AM
30 to 60 seconds! Holy moley!

We try to operate on the 3 seconds or less rule, mind you I think we need to do some pruning on the client side, we have a lot of libraries like JQuery and Twitter Bootstrap and now we're using Font Awesome, I know the graphics they use in those libraries are fairly small but still, it adds up over time.

It has to be said, we have a fairly minimalist design ethos so likely we're not pushing that much stuff out to begin with that isn't unique or cached data.

Sorry that was a typo, it should have said 60-300ms which is 2x to 10x slower.

Mr. Analog

Ahh, still that's a fairly long delay :noes:

What platform are you guys running?
By Grabthar's Hammer

Lazybones

Quote from: Mr. Analog on May 10, 2013, 12:01:02 PM
Ahh, still that's a fairly long delay :noes:

What platform are you guys running?

IIS 7 for the one app, but keep in mind some of that response time is because it is also the application server... thus why sicking a caching proxy in front or allowing more aggressive client side caching of images makes such a big difference.

This is also why many sites use a separate server or CDN network JUST for static content.

ALso this is not an in house developed app but a purchased package that happens to be a web app.

Mr. Analog

Ahh I see, yeah we use a separate SQL server cluster for our cached resources / service calls (thru AppFabric)

We're also moving to a round robin load balanced cluster for each of our layers (currently sessions are pinned). Ideally, we're moving toward a load based config but we just don't have the numbers to make that worthwhile (from what I understand)
By Grabthar's Hammer