Clear media search cache (11 posts)

  1. m1ndmaker
    Posted 2 years ago #

    Appearently WP chaches the search results within the media results. I could not find a way to clear this cache, and it turns out to be quite annoying.

    I have a large site with a few houndred images in the media library. In the 'Insert media' dialog, I start looking for some images by typing in the search phrase in the search box at the right top corner. If there are no results, I know I have to upload those images.

    So I upload them. Putting in the search terms again still does not find the images just uploaded although the filenames match the search terms. I then have to use different search terms to find these images.

    1) In the 'Insert media' uploader, I search for "wordpress". No results.
    2) I upload the images 'wordpress-screenshot-1.jpg', 'wordpress-screenshot-2.jpg' and 'wordpress-screenshot-3.jpg'.
    3) In the 'Insert media' uploader, I search again for "wordpress". No results. I then search for "screenshot" - the 3 files are found. I search for "press" - also works.

    By the looks of it the query results get cached somewhere. I tried to find out where - but no luck.

    Any help appreciated!

  2. Pioneer Web Design
    Posted 2 years ago #

    The reason no one has responded is that you are making statements that only you know to be accurate. Please have read:

  3. m1ndmaker
    Posted 2 years ago #

    Right. That answer was equally useful as no answer at all, thanks for that.

    I'm writing themes and plugins for wordpress since 2.2. I think I have left the 'Getting started' part behind a while ago.

    If you can't provide proactive and helpful answers, I recommend you don't.

  4. Pioneer Web Design
    Posted 2 years ago #

    Is WordPress the only search term that fails?

  5. m1ndmaker
    Posted 2 years ago #

    Of course not. There are no files called wordpress-screenshots-x. This was an example to illustrate the behaviour.

    However, I came to the conclusion it is not wordpress caching the search results, it is the browser (Firefox 26 in my case). It looks to me like the WordPress AJAX wrapper for the jQuery .ajax() function does use the default value for the setting cache, which is set to true. The search results are therefor being cached in the browser cache like every other web page as well. Unfortunately without the possibility to press F5.

    Looks like there is no way I could change this behaviour other than editing the corresponding files in wp-includes/. Which I of course don't want to get on with.

    It would be nice to have some kind of refresh button in the media uploader - clicking on it could perform an ajax request with cache set to false - and would therefor update the search results.

    Maybe I can find a way round to perform this using a plugin hook. Let's see.

  6. Pioneer Web Design
    Posted 2 years ago #

    WordPress AJAX wrapper

    Can you please be more detailed on this for the sake of this forum? What is the "WordPress AJAX wrapper"?

  7. m1ndmaker
    Posted 2 years ago #

    32	        // wp.ajax
    33	        // ------
    34	        //
    35	        // Tools for sending ajax requests with JSON responses and built in error handling.
    36	        // Mirrors and wraps jQuery's ajax APIs.


    Line 32.

    This class is being used for sending AJAX requests in the media browser/uploader. It is a wrapper for the jQuery .ajax() function: wp.ajax.send() calls $.ajax().

  8. Pioneer Web Design
    Posted 2 years ago #

    Great, now where does it cache anything? Or is that server-side specific?

  9. m1ndmaker
    Posted 2 years ago #

    Please be so kind and read my posts.

    I found out the Webbrowser caches the ajax results. Not wordpress.

    WordPress could avoid that caching by setting the 'cache' setting in the jQuery ajax call to false. That would probably solve it, but increase the traffic.

  10. Pioneer Web Design
    Posted 2 years ago #

    What happens if you turn caching off in your browser or affect the ability to set cached content by your server?

  11. webbistro
    Posted 2 years ago #

    Hello @m1ndmaker,

    Have you had any luck with solving this issue?


Topic Closed

This topic has been closed to new replies.

About this Topic