In this guide, we’ll walk you through disabling SiteGround Optimiser on specific WordPress pages on and for specific query string variables, like the search page.

Last updated: 12 Oct 2025

Reading time: 3 minutes

If you’re hosted on SiteGround and using the SiteGround Optimiser plugin to speed up your website, you might find that it can sometimes interfere with specific pages, especially those with dynamic content, query string variables, login forms, or personalised content. Disabling the cache for certain pages ensures they function correctly without serving outdated content.

In this guide, we’ll walk you through the steps to exclude specific pages from SiteGround Optimiser’s cache, helping you maintain both performance and functionality.

Disable SG Optimiser cache on the search page

If you view our search page, you’ll notice some filters in the sidebar to the right (on desktop).

For search to work as intended, each button transforms the search parameters to only show content from that post type. The query string parameters are arrays, which are URL encoded, which is why this:

https://bigsalami.co.uk/?s=seo&post_type[]=page&fs=1

looks like this:

https://bigsalami.co.uk/?s=seo&post_type%5B%5D=page&fs=1

When you change the post_type variable (e.g., from page to post), SiteGround optimiser will continue displaying the cached content from the first time this page was loaded, even though the query string is different.

In their article, SiteGround offers some options to disable cache on specific pages with the .htaccess file, but messing around with the .htaccess can render your site completely inoperable, and is more difficult to read and understand.

You can achieve this more easily with some PHP in your functions.php file (within your theme or child theme).

Prerequisites

If you’re wondering “which functions.php file should I edit”, then this is where your journey ends. Please find a WordPress specialist or contact us to help you. It’s a relatively quick and easy fix for us, but if you do this incorrectly, it can render your site completely inoperable.

If you developed your own theme, you can place this in your theme’s functions.php file, however if you’re using a third-party theme that updates automatically, any changes to the functions.php file will be overwritten when the theme is next updated, in which case you’ll need to add this code to the child theme.

Disable SiteGround Optimiser cache for specific query string variables

To disable cache for specific query string variables, use the following code snippet:

add_filter( 'sgo_bypass_query_params', 'add_sgo_bypass_query_params');
function add_sgo_bypass_query_params( $bypass_query_params ) {
	// Add custom query params, that will skip the cache.
	$bypass_query_params[] = 'query_param';
	$bypass_query_params[] = 'query_param2';
	return $bypass_query_params;
}

For the search page, adapt it to look like this:

add_filter( 'sgo_bypass_query_params', 'add_sgo_bypass_query_params');
function add_sgo_bypass_query_params( $bypass_query_params ) {
	// Add custom query params, that will skip the cache.
	$bypass_query_params[] = 's';
	return $bypass_query_params;
}

Further reading

SiteGround has a thorough article on this, which is almost impossible to find in Google unless you know exactly what you’re searching for, which is why we published this article.

You can find their article here.

Happy editing!

About the Author: Stephan

With 20 years of industry experience as a UX specialist, designer and developer, I enjoy teaching and sharing insights about UX, accessibility and best practices for e-commerce and the web.

Related insights