iSun
iSun

Reputation: 1754

How to expire a web-page immediately

I have a web page and I want to immediately expire it after loading, so If user wants to see my page code he should face with an error like this:

Document Expired

This document is no longer available.

To accomplish this idea, I set the following header on my page:

<?php header("Expires: " . gmdate('D, d M Y H:i:s \G\M\T', time() - 3600)); ?>

But seems it's not working correctly, any ideas?

Upvotes: 0

Views: 2248

Answers (3)

M C
M C

Reputation: 626

You cannot stop the User from browsing through your code, if he is knowledgeable. At best you can obfuscate your code using javascript tools like Htmlguardian.

But any user with some knowhow can completely restore the code since the Browser must parse your page to display it.

Upvotes: 1

KodeFor.Me
KodeFor.Me

Reputation: 13511

By doing that you are telling to the browser to stop caching your html document it self. In reality there is no way to protect your HTML/JS/CSS code.

There are several services that obfuscating JS/HTML but still your code is not safe. Anything comes into your computer belongs to you, it suffices to find the way to use it.

Anything comes into your computer, it is inside your computer, images, html, js, css, videos, audio, anything.

If you can find the way to use that data, then you can own that data.

Upvotes: 0

LevB
LevB

Reputation: 2366

"Document Expired" header inform browser do not cache page or flush cache, but do not protect from viewing page source.

Upvotes: 2

Related Questions