Check whether a page is Google Cached

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
alanchen
Forum Newbie
Posts: 1
Joined: Tue Apr 21, 2009 9:18 am

Check whether a page is Google Cached

Post by alanchen »

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 http://www.mysite.com, and I want to use it to check
whether http://www.yoursite.com is google cached.

It works as follows:

The user input the query:

http://www.mysite.com/test.php?site=www.yoursite.com

The php script will send the following request to the browser

http://www.google.com/search?q=cache:www.yoursite.com

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
coding

Thanks to all of you so much

Alan
Post Reply