Client question: How do you handle caching?

This came from a Tech Admin for one of our clients (non-sports site). Figured that it would be incredibly informative to share with everyone else.

NOTE: Even though this mentions the Drupal software package, the answer is applicable to any software package/content management system used within our hosting network.


I think I am about ready to do some optimization for the site. You say not to use any caching within Drupal. Are you including turning off the default caching and aggregating of css and javascript files within Drupal core as well, since it is usually considered best practice to leave that on? What caching system are you planning on using? Does it only work for anonymous users or for authenticated sessions as well? I am just wondering since this is a commerce site and has lots of forms. Most of those pages can’t be fully cached or the anti spam features will fail. If I know how you are planning on setting up the caching I will be better able to give you a list of things to disallow.

xCache is already enabled on the backend vServers, so all PHP code is opcode cached already.

NginX delivers all of your static assets (files, such as images, CSS style sheets and Javascript (that aren’t created on the fly, aka dynamically), straight HTML, XML files (in MOST cases)) on the load balancer automatically, by looking at the file extensions.
Really, all you need to do is ensure that your CSS style sheets and Javascript files are minified (a process that reduces extra white space and possibly even combines these files into larger singular files) and you’re set.

The Load Balancer will serve the minified versions unless the software package you use creates the files in PHP and adds weird variables at the end (such as filename.php?foo=bar).

Having Apache serve up minified CSS and Javascript files is actually a step backwards in internet technology. As long as your files are legitimately .css and .js, everything should be handled through the native load balancers properly!

This also means that you shouldn’t need to implement any additional or special caching protocols within your own scripts unless it’s absolutely necessary.