Caching and Mobile Stylesheets

The final checkbox in the main set of Super Cache options turns on mobile support. This doesn't mean much unless you're also running a second plugin that provides a mobile version of your site. To demonstrate how this works, I'll walk you through setting up Super Cache to work with WPTouch, the plugin that provides mobile versions of all sites on wordpress.com.

The WPTouch settings screen has a multitude of options. I won't discuss them all here; the ones I'm interested in showing you are in the Advanced Options box. Highlight the user agent strings as shown in Figure 11-7, copy them, and then head back over to the Super Cache settings.

Advanced Options

Choose to enable/disable advanced features & options available for WPtouch.

* WPtouch Restricted Mode attempts to fix issues where other plugins load scripts which interfere with WPtouch CSS and JavaScript.

Custom User-Agents Enter a comma-separated list of u enable WPtouch for a device that is officially supported.

The currently enabled user-agents a dream, incognito, tphone, (pod, mini

't currently

2J Enable Categories tab in the header 7 0 Enable Tags tab in the header? 0 Enable 5earch link in the header? O Enable Login/My Account tab in the header?

Display Upcoming Dates link in the header (requires CigPress 2.0.3 or higher) 7 Display Twitter link in the header (requires WordTwit 2,3.1 or higher) ?

0 Enable gravatars in comments □ Enable comments on pages 7

C! 1st visit mobile users will see desktop theme ? □ Enable WPtouch Restricted Mode 7

Custom user-agents

Figure 11-7. User agent strings in the WPTouch Advanced Options

First, in order to support WPTouch, you'll have to select Half On mode. Full On mode circumvents the user agent checking that allows mobile version plugins to work, so you'll have to use Half On mode if you want to use Super Cache alongside a mobile plugin. That's OK; for most sites, Half On is sufficient. Next, check off mobile device support and press Update Status.

Now that mobile device support is on, you need to prevent Super Cache from displaying the cached pages to mobile user agents. Scroll down and find the Rejected User Agents box, as shown in Figure 11-8. Paste the user agent strings you copied from the WPTouch settings screen and remove the commas, placing each user agent on its own line. Press Save UA Strings, and you've enabled mobile support.

bmps in (he HTTF Uiet *g*m' henk* (hit erevon W-Och* uOii<i« bw. soldera, and crmten' requests. Noie that lupir cached lUej ut Mli wra id Owm igtri rt it*r an»«3v tab», bmps in (he HTTF Uiet *g*m' henk* (hit erevon W-Och* uOii<i« bw. soldera, and crmten' requests. Noie that lupir cached lUej ut Mli wra id Owm igtri rt it*r an»«3v tab»,

Debug Seti.ngi

Fut pfofclpn* wtii (he Bhfln Of attaining it -«re- II çaji send you dit.g eeuii gr log Them w a fWf ti your uclic directly. » a Ittt s easier laces the prefrlem ihu ctting ihe otne «Ii dti.' cht n-} nie.

Debug Seti.ngi

Fut pfofclpn* wtii (he Bhfln Of attaining it -«re- II çaji send you dit.g eeuii gr log Them w a fWf ti your uclic directly. » a Ittt s easier laces the prefrlem ihu ctting ihe otne «Ii dti.' cht n-} nie.

Urtoflgirfl □ irijInj tflM11»» tmU

Figure 11-8. Pasting the mobile user agents into the Super Cache list of rejected user agents

Figure 11-8. Pasting the mobile user agents into the Super Cache list of rejected user agents

However, there's one more step you need to take: deleting the existing cache. Any time you change the Super Cache settings, you need to delete the cache so the cached pages will be rebuilt according to your new settings. Once you've saved the UA strings, scroll back up to the Cache Contents section and press Delete Cache.

WPTouch is not the only mobile version plugin by any means, but mobile support in Super Cache works essentially the same way with all the other plugins.

0 0

Post a comment