Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Jose Morales-Mendizabal
Jose Morales-Mendizabal
19,175 Points

Wordpress native search form takes long time to display results

Hi, I've made a custom Wordpress theme for a client thanks to Zac Gordon 's lessons. The site works great and all, however there seems to be a small issue when one searches for keywords through the search form that can be found on the page at www.juanturcios.com/archive When I search for a keyword that I know for sure that is somehwere in a post such as "wedding" or "photography" the search results are returned within seconds. However when I search for a silly keyword that I know is NOT mentioned in any post such as "dragon sillystring" Wordpress takes about a minute or more before returning the 404-ish page I designed to tell the user no posts were found that matched the keywords entered.

Is this normal behavior? Or do you think it is taking this long because I have the W3 Total Cache plugin caching the database? Any tips on improving the performance of the search form?

I have included the code I wrote in the searchform.php that I included in my custom theme if you need to see what's going on under the hood.

Thanks!

    <div><label class="screen-reader-text" for="s"><i class="fa fa-search fa-lg search-icon"></i></label>
        <input type="text" value="" name="s" id="search-field" autocomplete="off" placeholder="Search for a photoshoot..."/>
    <input type="hidden" value="post" name="post_type" id="post_type" />
        <input type="submit" id="searchsubmit" value="Search" />            
    </div>
</form>

3 Answers

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hey Jose Morales, honestly a number of sites don't really need to have heavy caching to perform quickly. I'd use Pingdom Tools to test the site with and without the plugin. You might also want to play around with the cache settings. There may be one little setting that you can disable that will solve the problem.

Jose Morales-Mendizabal
Jose Morales-Mendizabal
19,175 Points

You're absolutely right. I did some experimenting tonight and turns out caching the WP Object was hindering the search load time. I've turned off that setting and now the website is as performant as it can be for the time being. Thanks for your helpful insights!

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

If it's possible, I'd be curious how it performs if you set it up locally

Jose Morales-Mendizabal
Jose Morales-Mendizabal
19,175 Points

Thanks for the quick response Zac Gordon. turns out it WAS the cache. I emptied the cache and deactivated the plugin and it now works super fast. Do you think in this case database caching hinders performance and should consider not using the plugin? or should I not care about users potentially waiting minutes due to search for irrelevant keywords and activate the plugin? The thing is that since the website I designed is for a photographer and thus heavy on images, not including the plugin results in slower load times.

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Actually this is not a super uncommon complaint. There are some native search engine alternative plugins that you might want to try and see if they're faster.

I don't think this is caching related, although you could easily delete your caches and turn off the plugin to test.