这是我写的代码
索引.php:
<?php session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
?>
<!DOCTYPE html>
<html>
<head>
<title>Student-login</title>
<link href='http://fonts.googleapis.com/css?family=Shadows+Into+Light' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="shortcut icon" href="css/favicon.jpg"/>
<link href='http://fonts.googleapis.com/css?family=Questrial' rel='stylesheet' type='text/css'>
</head>
<body>
<div class="bodybg"></div>
<div class="main-form">
<h1>Student Login</h1>
<form class="login" action="database.php" method="post">
<input type="text" placeholder=" User name(*)" name="username" required></input><br>
<input type="password" placeholder=" Password(*)" name="password" required>
</input><br>
<input type="submit" value="Login" name="btnlogin"></input><br>
<div class="button"><a href="login.php">Register</a></div>
<!--flash message-->
<div id="message">
<?php
if(isset($_SESSION['success'])){
echo $_SESSION['success'];
//echo "<p class='message'>hello this world!!</p>";
}else{
echo " ";
}
$_SESSION['success']=' ';
?>
</div>
</form>
</div>
<div id="heading">
<p id="p1">American Internation University-Bangladesh</p>
<p id="p2">Thesis Compilation</p>
</div>
<div id="content">
<div id="prev"><i class="fa fa-chevron-left fa-1x"></i></div>
<div id="next" d><i class="fa fa-chevron-right fa-1x"></i></div>
<div id="pager"></div>
<div id="slider">
<div class="item">
<img src="img/1.jpg">
<div class="info">
<h2>Picture 1</h2>
<p>This is the library</p>
</div>
</div>
<div class="item">
<img src="img/2.jpg">
<div class="info">
<h2>Picture 2</h2>
<p>This is the Book</p>
</div>
</div>
<div class="item">
<img src="img/3.jpg">
<div class="info">
<h2>Picture 3</h2>
<p>This is the Pen</p>
</div>
</div>
<div class="item">
<img src="img/4.jpg">
<div class="info">
<h2>Picture 4</h2>
<p>This is the literature</p>
</div>
</div>
<div class="item">
<img src="img/5.jpg">
<div class="info">
<h2>Picture 5</h2>
<p>This is the Research</p>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/cycle.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
和 home.php:
<?php
session_start();
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Cache-Control: no-cache");
header("Pragma: no-cache");
?>
<!DOCTYPE html>
<html>
<head>
<title>Home</title>
<link href='http://fonts.googleapis.com/css?family=Shadows+Into+Light' rel='stylesheet'
type='text/css'>
<link rel="stylesheet" type="text/css" href="css/main.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
<link rel="shortcut icon" href="css/favicon.jpg"/>
</head>
<body class="body">
<div class="menu">
<div class="home">
<a href="Home.html">Home</a>
</div>
<div class="profile">
<a href="profile.html">Profile</a>
</div>
<div class="contact">
<a href="contact.html">Contact</a>
</div>
<div class="logout">
<a href="database.php?laction">Logout</a>
</div>
</div>
<div class="transparent">
</div>
<div class="content">
<div id="message">
<?php
if(isset($_SESSION['success'])){
echo $_SESSION['success'];
//echo "<p class='message'>hello this world!!</p>";
}else{
echo " ";
}
$_SESSION['success']=' ';
?>
</div>
</div>
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
问题是这应该通过 header() 函数阻止浏览器中的缓存,但是在加载页面后,后退按钮将我带到上一页,浏览器的前进按钮将我带到下一页任何人都可以帮助如何防止此浏览器缓存或为什么我的代码在这里不起作用?
最佳答案
感谢大家帮助我,但我找到了一种强制浏览器阻止缓存的方法,我使用了以下代码:
header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0 "); // Proxies.
这里是引用: Making sure a web page is not cached, across all browsers 而且效果很好。
关于php - 防止浏览器后退按钮缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31735428/
我正在尝试在Ruby中制作一个cli应用程序,它接受一个给定的数组,然后将其显示为一个列表,我可以使用箭头键浏览它。我觉得我已经在Ruby中看到一个库已经这样做了,但我记不起它的名字了。我正在尝试对soundcloud2000中的代码进行逆向工程做类似的事情,但他的代码与SoundcloudAPI的使用紧密耦合。我知道cursesgem,我正在考虑更抽象的东西。广告有没有人见过可以做到这一点的库或一些概念证明的Ruby代码可以做到这一点? 最佳答案 我不知道这是否是您正在寻找的,但也许您可以使用我的想法。由于我没有关于您要完成的工作
我的主要目标是能够完全理解我正在使用的库/gem。我尝试在Github上从头到尾阅读源代码,但这真的很难。我认为更有趣、更温和的踏脚石就是在使用时阅读每个库/gem方法的源代码。例如,我想知道RubyonRails中的redirect_to方法是如何工作的:如何查找redirect_to方法的源代码?我知道在pry中我可以执行类似show-methodmethod的操作,但我如何才能对Rails框架中的方法执行此操作?您对我如何更好地理解Gem及其API有什么建议吗?仅仅阅读源代码似乎真的很难,尤其是对于框架。谢谢! 最佳答案 Ru
我试过重新启动apache,缓存的页面仍然出现,所以一定有一个文件夹在某个地方。我没有“公共(public)/缓存”,那么我还应该查看哪些其他地方?是否有一个URL标志也可以触发此效果? 最佳答案 您需要触摸一个文件才能清除phusion,例如:touch/webapps/mycook/tmp/restart.txt参见docs 关于ruby-如何在Ubuntu中清除RubyPhusionPassenger的缓存?,我们在StackOverflow上找到一个类似的问题:
尝试在我的RoR应用程序中实现计数器缓存列时出现错误Unknownkey(s):counter_cache。我在这个问题中实现了模型关联:Modelassociationquestion这是我的迁移:classAddVideoVotesCountToVideos0Video.reset_column_informationVideo.find(:all).eachdo|p|p.update_attributes:videos_votes_count,p.video_votes.lengthendenddefself.downremove_column:videos,:video_vot
我希望用户从一个模型的三个选项中选择一个。即我有一个模型视频,可以被评为正面/负面/未知目前我有三列bool值(pos/neg/unknown)。这是处理这种情况的最佳方式吗?为此,表单应该是什么样的?目前我有类似的东西但显然它允许多项选择,而我试图将它限制为只有一个..怎么办? 最佳答案 如果要使用字符串列,让我们说rating。然后在你的表单中:#...#...它只允许一个选择编辑完全相同但使用radio_button_tag: 关于ruby-on-rails-Rails单选按钮-模
我有一个ActiveRecord对象,我想在不对模型进行永久验证的情况下阻止它被保存。您过去可以使用errors.add执行类似的操作,但它看起来不再有效了。user=User.lastuser.errors.add:name,"namedoesn'trhymewithorange"user.valid?#=>trueuser.save#=>true或user=User.lastuser.errors.add:base,"myuniqueerror"user.valid?#=>trueuser.save#=>true如何在不修改用户对象模型的情况下防止将用户对象保存在Rails3.2中
我要下载http://foobar.com/song.mp3作为song.mp3,而不是让Chrome在其native中打开它浏览器中的播放器。我怎样才能做到这一点? 最佳答案 您只需要确保发送这些header:Content-Disposition:attachment;filename=song.mp3;Content-Type:application/octet-streamContent-Transfer-Encoding:binarysend_file方法为您完成:get'/:file'do|file|file=File.
基本上,我试图在用户单击链接(或按钮或某种类型的交互元素)时执行Rails方法。我试着把它放在View中:但这似乎没有用。它最终只是在用户甚至没有点击“添加”链接的情况下调用该函数。我也用link_to试过了,但也没用。我开始认为没有一种干净的方法可以做到这一点。无论如何,感谢您的帮助。附言。我在ApplicationController中定义了该方法,它是一个辅助方法。 最佳答案 View和Controller是相互独立的。为了使链接在Controller内执行函数调用,您需要对应用程序中的端点执行ajax调用。该路由应调用rub
我在这方面尝试了很多URL,在我遇到这个特定的之前,它们似乎都很好:require'rubygems'require'nokogiri'require'open-uri'doc=Nokogiri::HTML(open("http://www.moxyst.com/fashion/men-clothing/underwear.html"))putsdoc这是结果:/Users/macbookair/.rvm/rubies/ruby-2.0.0-p481/lib/ruby/2.0.0/open-uri.rb:353:in`open_http':404NotFound(OpenURI::HT
我在ruby表单中有一个提交按钮f.submitbtn_text,class:"btnbtn-onemgt12mgb12",id:"btn_id"我想在不使用任何javascript的情况下通过ruby禁用此按钮 最佳答案 添加disabled:true选项。f.submitbtn_text,class:"btnbtn-onemgt12mgb12",id:"btn_id",disabled:true 关于ruby-on-rails-如何在Rails中添加禁用的提交按钮,我们在St