Jump to content

Check whether a page is Google Cached


Recommended Posts

Hi, everyone,


I want to write a small PHP script test.php that can determine whether a

webpage is Google Cached.


Assuming it is uploaded to www.mysite.com, and I want to use it to check

whether www.yoursite.com is google cached.


It works as follows:


The user input the query:




The php script will send the following request to the browser




in the background.


And if the returned result contains a string "This is Google's cache of",

then the page is cached, so the php script can display


"Your site is cached by Google"


otherwise, it will say


"Your site is not cached by Google"


Just wonder how to implement such a feature, can anyone write a simple

sample so that I can use as a startpoint as I am a totally new guy in PHP



Thanks to all of you so much





Link to comment
Share on other sites

This isn't the best thing to start learning PHP with but if you want to do this you will need to look into

PHP $_GET/get

PHP forms (if you want one)

and then maybe file_get_contents and maybe a regex or just some string functions to search for the term in the results which say whether it is cached

Link to comment
Share on other sites

yer gunna want to use cURL for this... php.net/curl


$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.google.com/search?q=cache:www.yoursite.com');


that would set the entire page specified into the $o variable... in which you just need a simple eregi() to check for the 'This is Google's cache of' string...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.