RESS with Server Side Caching

During my presentation last weekend at WordCamp Scranton, someone asked how using device detection would work if they were using server side caching. There was a bit of back and forth, and basically the situation that this person was facing was this: they had server side caching enabled on their server and they had some very dynamic pages, with content coming in from multiple sources. They ended up having issues with some of the content that is dynamic being cached on the server and not showing new content when it was available.To get around this they implemented a shortcode system to tell the server to not cache a portion of that content that just the description of made my head spin.

Now don’t read that the wrong way, big kudos to them to create a solution that works well for them and has a smaller footprint than a hardcoded solution probably would.

I’ve have server caching enabled on most of my sites(including this one) and have never run into an issue like that. So, unfortunately, I wasn’t a whole lot of help to them.

Static Caching

So I did a bit of digging and discovered some things. Most server caching is static caching. What that means is that when caching is enabled on the server, the server will cache all of your static file such as CSS, JS, images, HTML…. basically anything that will stay the same unless the file is updated. Siteground, which I work with a lot, has Super Cache that is a static cache. Memcached, which is a popular open source cache system, is static cache as well. There are countless other examples too.

Static Caching is what a typical WP caching plugin does.

WordPress goes a step farther by default and uses object caching. You can cache a bit of data (say something pulled from the database) and then, later on in the page you can use it again without pinging the database a second time. It uses that data to create an object which it stores if it is needed again. WP Tavern has a great article on caching with WordPress. It’s definitely worth the quick read.

Dyanamic Caching Systems

So is that it…?

Sort of but not really.

There are ways to cache dynamic pages on a server (obviously, given the situation of the attendee.) But these are caching systems that don’t seem to be very common among “commercial hosting companies” (i.e the Sitegrounds, Blue Hosts, GoDaddys, etc of the world.)

So is there a way to make server side device detection work on these systems? Sure. How? There are as many ways as there are dynamic server caching systems.

And while that answer might seem like a cop out, answer me this: what is the purpose of caching a site/application that by it’s very nature should be dynamic? I hate to say it, but if you are using a dynamic caching system with a dynamic website/application, you’re asking for trouble. It seems to me that a static caching system would serve both the site/application and the user a lot better.

The user won’t have the potential to not have the latest content while the developer won’t have to maintain and keep track of an elaborate system of workarounds or an increased codebase due to making the dynamic cache play nice with device detection.

Static cache would cache the necessary resources that are used but aren’t updated very often while keeping the application/site as flexible as possible so that it runs the way that it was intended to.

So what do you think? Do you have any experience with using device detection with a dynamically caching server? I’d love to hear about it.