Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

script for static pages

need a script to avoid google cache



4:35 pm on May 7, 2004 (gmt 0)

10+ Year Member


I am using a cloaker that allows me to create templates and static pages. The static pages I can create with HTML and my own copy.

I have read here at WebmasterWorld that I should not use the tag "<META NAME="ROBOTS" CONTENT="NOARCHIVE">" because it will be suspicious for the engines.

So, my questions is what script or iframe should I use? to redirect where? and where should I place it? Also, I would like to know if this script would prevent my cloaked page to be cached.




5:17 pm on May 7, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

The only thing that will prevent an indexed page from being cached is the NOARCHIVE meta tag. You could possibly use a JavaScript to redirect visitors to another website, but such redirects are visible and it's possible Google and other SEs will detect them as well and penalize the page.

The NOARCHIVE tag is suspected as a warning flag to search engines, but it is only a suspicion. There is no evidence that Google or any other search engine singling out sites with the NOARCHIVE meta tag for further review.


12:07 am on May 11, 2004 (gmt 0)

10+ Year Member

You need to call this script from an external file in the header of each page that you do not want to 'appear' as being cached. As long as the browser doesnt have JavaScript disabled then the user will not see the cached version.

<!-- hide
if (location.href.indexOf("cache")!= -1)
// end hide -->


1:39 pm on May 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Here's a question on a related topic...

Is there a way to generate a frameset on the fly in a document? Using the above JavaScript code, the URL would change in the location bar. If you were able to generate a frame on the fly, the URL wouldn't change and the person trying to view the cache of your cloaked page would be less suspicious.


2:43 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Yes, you could. An easy way to do this is with iframes and css, not frames, since frames require a different document structure.


document.write('<div id="iframeContainer"><iframe src="non-cached-page-version.html"></iframe</div>');

In your css have the

body, html {

div#iframeContainer {
iframe {

when the page is loaded and it's in the cache the javascript will write this out, then the iframe will be loaded within about 1 second or so, I haven't actually tested this exact version, you might have to set z-index for the cached content section also, play around with it and see, but this should work fine, I use a technique like this to take over a page on a bulleten board type thing.


5:48 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Does your code wipe out the box Google has at the top of the cached page? Wouldn't want to do that...

I do like the idea :)


7:35 pm on May 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

Yes, I have a site where if you view the cached version of the page it takes over the whole page, goes over the google cache stuff, you'd have to experiment a bit with the positioning to find the sweet spot, slightly tricky however since you can't update the google cache page until google recaches your page.

It has to be absolutely positioned since you are trying to cover another part of the page, I think, it's hard to experiment with something like the google cache, although actually now that I think of it all you have to do is copy the html from a cached page, dump the content part, then construct a sample page using the above code, tweak the positioning til it works right. By my count if text size is normal the google cache part is about 205 px high, give or take, 200 would probably be safe, in that case make top: 200px; and it should theoretically line up decently, you'd also have to tweak the heights of the iframe, ideally it would be the document height.

Also, I forgot this, you need to set the background color for the iframe div container as white or whatever background color your site has, or else you'd see the cloaked content for a few seconds while the iframe loaded, possible anyway.

One possible way around the positioning might be to place your entire page, including the cloaked page, inside a div, make that div have position: relative, then put this sub div/iframe thing inside of that with position:absolute, I think that might work, since then the absolute positioning is relative to the container, not the google page. Now that I think about it, that would almost definitely work, maintaining the top:0 relative to the bottom of the google info section.


...google header page code, table etc....
<div id="mainRelativeDiv">
<script type="text/javascript">document.write('<div id="iframeContainer"><iframe src="non-cached-page-version.html"></iframe</div>');</script>
...your cloaked page html...
.. google footer page code....

Another thing you might be able to do is put the cloaked content in its own div, then have the same 'cache' detection write out some css that sets the div id container for the cloaked content to display:none, which would make it totally invisible to a viewer unless they looked at the source code. So many options with CSS.., that way if your cover iframe page ran shorter than your cloaked content you would never see the cloaked content....


Featured Threads

Hot Threads This Week

Hot Threads This Month