Closed centminmod closed 3 years ago
Allowing search results to be cached is a feature that I think would be a good idea to add. In my opinion adding an option in the Cache Behavior setting would work best.
The default search format (e.g. ?s=query
) should be able to be cached, which would still allow the rewritten search results (e.g. /search/query/
) to be cached. The cached file and the directory names in wp-content/cache/cache-enabler/example.com/
should be the same regardless of the search format used.
I'll start working on this for version 1.3.7.
Great news ! Not sure if it's something you can resolve too but with my search cache method it doesn't work with WPML language plugin as that generates urls like domain.com/en/?s=query or domain.com/de/?s=query which caching doesn't pick up for separate languages. Maybe something to keep in mind for 1.3.7+ ๐
I'll make sure to check that out. It won't change the release date, however, this will be available in version 1.4.0 instead as that will be the next version released.
The way that I want to implement allowing search results to be cached has been more complicated than I had previously anticipated. Due to this I've pushed this feature to be released in version 1.5.0 instead. I apologize for the delay.
What about for now just giving us a admin side toggle option to exclude search ? It would aid in your planned method ? and it shouldn't interfere too much with future work/plans ?
Would allow folks like myself to just roll out Cache Enabler search cache via something like https://github.com/centminmod/pretty-search-url at Nginx level totally bypassing PHP processing.
diff -u cache_enabler.class.php-orig cache_enabler.class.php-removesearch
--- cache_enabler.class.php-orig 2020-07-17 05:33:33.933006105 +0000
+++ cache_enabler.class.php-removesearch 2020-07-17 05:34:17.572342714 +0000
@@ -1407,7 +1407,7 @@
}
// conditional tags
- if ( self::_is_index() OR is_search() OR is_404() OR is_feed() OR is_trackback() OR is_robots() OR is_preview() OR post_password_required() ) {
+ if ( self::_is_index() OR is_404() OR is_feed() OR is_trackback() OR is_robots() OR is_preview() OR post_password_required() ) {
return true;
}
@centminmod We decided we're going to add a filter hook to allow this instead of what was previously planned. I unfortunately didn't quite get to adding and updating our hooks in version 1.5.0, but this is on the top of my list todos so you shouldn't have to continue to modify the plugin much longer to cache search results. ๐
Cheers @coreykn thanks for the update ๐
I've managed to make Cache Enabler cach search results when setup via advanced caching with Nginx server as outlined at https://github.com/centminmod/pretty-search-url. But would be much easier if you can update Cache Enabler to support a configurable admin option as to whether search is cacheable or not. This would allow folks to not have to modify
cache_enabler.class.php
with https://github.com/centminmod/pretty-search-url plugin and nginx changes
with wordpress search cached
load test with my forked wrk
direct query search cached
versus with wordpress search non-cached
compared to default without wordpress search cache
cached search at 95,189 OR 104,448 requests/sec versus non-cached search at 332 requests/sec