在HTML / PHP中启用表单缓存
I am going a little crazy here trying to find a solution to something that is probably pretty straight forward.
I have a group of reports on an intranet (not accesible to the outside world) and each report has an input form that has a bunch of HTML inputs that vary the report data.
Problem being when you hit back to the form from the report the form is reset to it's original state. I want it to cache (remember the HTML input variables) and all I can find is how to turn caching off, I want it on! I would prefer not to do this with $_SESSION and $_COOKIE storing as I have 120 reports with roughly 10 or so inputs each, so its going to take forever to store everyone of them and re-load variables on refresh.
I am not the server administrator, but I beleive we are running Apache 2.2 web server. These are all PHP/HTML based pages. Any advice would be great!
It is not to do with my Browser as other forms are being cached. I am more looking into what modules on the server need to be activated to allow caching and what notes I should put in the header of the forms to allow caching. The intranet runs through a proxy so I am thinking I will need cache-control to be public.
EDIT:
When I run the form page, the HTTP headers show me this which I feel should be changed:
(under Response Headers)
X-Powered-By: PHP/5.3.3
Via: *[REMOVED]*
Server: Apache/2.2.3 (Red Hat)
Proxy-Connection: Keep-Alive
Pragma: no-cache
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Date: Wed, 13 Feb 2013 23:33:32 GMT
Content-Type: text/html; charset=UTF-8
Content-Length: 5191
Connection: Keep-Alive
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
I have a feeling I need to change the Cache-Control and Pragma values. Anyone know how to acheive this?
我在这里试图找到一个可能非常直接的解决方案时有点疯狂。 p >
我在Intranet上有一组报告(不可访问外部世界),每个报告都有一个输入表单,其中有一堆HTML输入可以改变报告数据。 p> \ n
问题是当您从报表中回到表单时,表单将重置为其原始状态。 我希望它缓存(记住HTML输入变量),我能找到的就是如何关闭缓存,我想要它! 我宁愿不使用$ _SESSION和$ _COOKIE存储,因为我有120个报告,每个报告大约有10个左右,所以它将永远存储它们的每个人并在刷新时重新加载变量。 p>
我不是服务器管理员,但我相信我们正在运行Apache 2.2 Web服务器。 这些都是基于PHP / HTML的页面。 任何建议都会很棒! p>
这与我的浏览器无关,因为正在缓存其他表单。 我更关注服务器上需要激活哪些模块以允许缓存以及我应该在表单的标题中添加哪些注释以允许缓存。 内联网通过代理运行,所以我想我需要将缓存控制公开。 p>
编辑: p>
当我运行表单页面时 ,HTTP标题显示我认为应该更改的内容: p>
(在响应标题下) p>
X-Powered-By: PHP / 5.3.3
Via:* [REMOVED] *
服务器:Apache / 2.2.3(Red Hat)
代理连接:Keep-Alive
Pragma:no-cache
Expires:Thu,19 1981年11月08:52:00 GMT
日期:2013年2月13日星期三23:33:32 GMT
内容类型:text / html; charset = UTF-8
Content-Length:5191
Connection:Keep-Alive
Cache-Control:no-store,no-cache,must-revalidate,post-check = 0,pre-check = 0
code> pre>
我有一种感觉,我需要更改Cache-Control和Pragma值。 有人知道如何实现这个目标吗? p>
div>
trying adding these headers to the top of the page:
header("Cache-Control: private, max-age=10800, pre-check=10800");
header("Pragma: private");
header("Expires: " . date(DATE_RFC822,strtotime("+2 day")));
NOTE: if the form submits and post data to a second page, you may want to put it at the top of both pages. also, make sure the code is after any session_start(); if you are using sessions.
Try setting the autocomplete attribute of the inputs to on.
<input name="myinput" autocomplete="on" type="text">