Caching Pages with GET querystrings
-
I think I have a bug to report. I’ve made some custom pages that display different content depending on the GET query strings, and therefore need to cache them as different pages as appropriate.
WP Super Cache has the option to cache/not cache pages with GET querystrings (“Don’t cache pages with GET parameters”), but the code doesn’t enforce this setting. At least, not in my experience.
From the trunk of the source code on Trac:
trunk/wp-cache-phase2.php, line 48:
if ( $wp_cache_no_cache_for_get && false == empty( $_GET ) && false == defined( 'DOING_CRON' ) ) { if ( isset( $wp_super_cache_debug ) && $wp_super_cache_debug ) wp_cache_debug( "Non empty GET request. Caching disabled on settings page. " . print_r( $_GET, 1 ), 1 ); return false; }
Here we’re checking to see if the DONT CACHE pages with GET args setting is enabled, and if so, and there’s a GET string, don’t cache. All is well. But here,
trunk/wp-cache-phase2.php, line 73:
if ( !empty( $_GET ) ) { if ( isset( $GLOBALS[ 'wp_super_cache_debug' ] ) && $GLOBALS[ 'wp_super_cache_debug' ] ) wp_cache_debug( 'Supercache caching disabled. Only using wp-cache. Non empty GET request. ' . print_r( $_GET, 1 ), 5 ); $super_cache_enabled = false; }
We immediately throw out caching of this page if the GET string is not empty, regardless of what that option says.
Ideally I’d like to cache versions of my page with each querystring possibility. Changing the second block of code here (and another similar section) to respect that option in this file does not lead to supercached versions of pages with querystrings. Everything defaults to standard caching using wp-cache (not gzipped, and not mapped directly in my nginx config, so processing still has to happen through PHP instead of serving a static page).
Is this something that is in the works? If not, why even offer that configuration option?
I could go down the rabbit hole further but it’d have to be in my spare time when I’m not on the clock… ??
Thanks for reading this over. You’ve built a great plugin.
- The topic ‘Caching Pages with GET querystrings’ is closed to new replies.