WordPress.org

Ready to get started?Download WordPress

Forums

WP Super Cache
Redirect a user-agent to an uncached home page? (6 posts)

  1. Delete Me
    Member
    Posted 2 years ago #

    I have a specific user-agent that crawls my home page to ensure certain PHP code on there is active and working. The problem is, it can't detect it when the home page is cached. Since I'd like to keep my home page cached all the time, I want ONLY this user-agent to be served the uncached version of my front page. I thought I could do this in the settings but Super-Cache only has the ability to prevent a user-agent from triggering a wp-cache, while any existing super-cache will still be served to it.

    Is there a way to set this up? I think there was a rewrite you could do in htaccess that could accomplish this, but the only snippet I found looked very convoluted to me and was tailored for mobile browsers.

    Any advice appreciated!

  2. Delete Me
    Member
    Posted 2 years ago #

    Anyone? I know W3 Total Cache and Hyper-Cache can accomplish this, why not Super-Cache?

  3. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Out of the box Supercache can't do that, but as you found, you can use a RewriteCond to stop Supercache serving the cache file. You'll also probably want a Supercache plugin that modifies the cache_key and sets the constant DONOTCACHEPAGE so the page isn't cached with the new cache_key.

    Or you can call your PHP script using Javascript or have that PHP in a separate url, off your homepage.

  4. Delete Me
    Member
    Posted 2 years ago #

    Such a solution is beyond the scope of my skills to put together though. I think the rewrite solution is the simplest since I only require the home page to be uncached for a particular user-agent, but I wouldn't know how to write it properly.

    If I reimbursed you, would you be willing to put together a rewrite solution for me (presuming this is indeed the easiest to do). Let me know if you're interested.

  5. Donncha O Caoimh
    Member
    Plugin Author

    Posted 2 years ago #

    Unfortunately I don't have time to take on extra work, sorry. Why don't you modify your script so it fetches a PHP script directly?

  6. Delete Me
    Member
    Posted 2 years ago #

    I used the dynamic_content tag to wrap around the PHP code in question that needed to stay dynamic for this crawler. It's not ideal but it appears to be working (before it was outputting the text of the code on uncache dpages for some reason.) Will continue to test!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic