I’m implementing a site that allows users to switch stylesheets (to show a high contrast version for people with vision impairments). The switcher essentially just changes the <link>
ref to whichever stylesheet is appropriate.
However, I just realised that this will lead to problems when I switch on caching (either using WP Supercache or W3 Total Cache) – as only one version of the page will be cached and thus displayed to the user.
Any thoughts on possible solutions?
3 Answers
I use W3TC, so these are approaches that I can come up with it for it:
-
Fragment caching to exclude that part of page, will reduce cache effectiveness overall.
-
Identify page with switched stylesheet by query argument, disable caching of such pages.
-
Identify page with switched stylesheet by URL endpoint, disable caching of such by mask.
-
Implement stylesheet switch via JavaScript (not really W3TC-specific).