简体   繁体   English

如何立即使网页失效

[英]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? 但是似乎无法正常工作,有什么想法吗?

“文档已过期”标头告知浏览器不缓存页面或刷新缓存,但不保护其免于查看页面源。

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 . 充其量您可以使用Htmlguardian之类的javascript工具来混淆代码。

But any user with some knowhow can completely restore the code since the Browser must parse your page to display it. 但是,任何具有专业知识的用户都可以完全还原代码,因为浏览器必须解析您的页面才能显示它。

By doing that you are telling to the browser to stop caching your html document it self. 这样,您就告诉浏览器停止自行缓存html文档。 In reality there is no way to protect your HTML/JS/CSS code. 实际上,没有办法保护您的HTML / JS / CSS代码。

There are several services that obfuscating JS/HTML but still your code is not safe. 有一些混淆JS / HTML的服务,但是您的代码仍然不安全。 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. 任何东西都进入您的计算机,它在您的计算机内部,图像,html,js,css,视频,音频等等。

If you can find the way to use that data, then you can own that data. 如果您找到使用该数据的方法,则可以拥有该数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM