English 中文(简体)
how to tell clicking "back" to load cache?
原标题:

I would like for my site when someone clicks "Back" or "Forward" for the server to tell the browser to load the cache instead of reloading the entire page. I ve tested some headers and done research, but I can t seem to get this to function as intended.

Update: The if-modified since header is not something I d like to do. There s got to be more general options when it comes to caching. Even if it doesn t work in every browser (though that would be ideal) even just Firefox/Chrome would be excellent.

最佳回答

I think you ll find that no matter what you do, the Back button functionality may or may not listen...the functionality differs from browser to browser and isn t up to the page being viewed.

There are plenty of tips and tricks for getting the browser to do what you want...but in the end it s up to whoever coded the browser if they want to listen or not.

问题回答

Check for the If-Modified-Since header before you output anything --- if it is recent enough, return a 304 Not Modified http status code and do not output the page.

You can conrol this behaviour with the Cache-Control header. This tutorial seems to be fairly comprehensive: Caching Tutorial

As far as i know there is no other way then using something like ZendCache or MemCache for those kind of things.

There reason is, in my optionion, that the server can t tell if the browser got the page cached or not so the server always send the full content, and executing the php script.

Using a seperate cache server (like zend or memcache) you can just forward the plain html without going through the whole script again.





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签