473,414 Members | 1,697 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

If-modified-since HTTP compliant!

Hi,

is there a HTTP-compliant implementation of If-Modified-Since-, If-Match,
If-None-Match, If-Range and so on?

I want my PHP-script to act exactly as if it was a static HTML-page
delivered directly from Apache.

I think this isn't easy to implement, especially if you take also weak and
strong validators into account.

Chris
Aug 7 '05 #1
6 2079
Chris wrote:
is there a HTTP-compliant implementation of If-Modified-Since-,
If-Match, If-None-Match, If-Range and so on?

I want my PHP-script to act exactly as if it was a static HTML-page
delivered directly from Apache.

I think this isn't easy to implement, especially if you take also
weak and strong validators into account.


To implement support for the if-modified-since header and when running
Apache, you would put something like the following on top of your page:

$request = array_change_key_case(apache_request_headers(), CASE_LOWER);
if (isset($request['if-modified-since'])) {
if (filemtime(__FILE__) > strtotime($request['if-modified-since'])) {
header("HTTP/1.1 304 Not Modified");
exit;
}
}

The key here is the apache_request_headers() function, which is used to
parse the request headers.
JW

Aug 7 '05 #2
On Sun, 7 Aug 2005 14:07:23 +0200 Janwillem Borleffs wrote :
To implement support for the if-modified-since header and when running
Apache, you would put something like the following on top of your page:


Thank you, Janwillem.

There are many examples codes like you posted on the net. They'll probably
all work. The problem is to find a *HTTP-compliant* implementation.

- Chris
Aug 7 '05 #3
Chris wrote:
There are many examples codes like you posted on the net. They'll
probably all work. The problem is to find a *HTTP-compliant*
implementation.


Then I'm not sure what you mean with HTTP-compliant. IMO, HTTP compliancy is
enforced by sending a response according to HTTP specifications for a
specific header.

If you mean that you would like to have an implementation which works for
all webservers, basically the only difference will be the way you retrieve
the request headers and you will have to test this for each individual
webserver.
JW

Aug 7 '05 #4
On Sun, 7 Aug 2005 15:25:50 +0200 Janwillem Borleffs wrote :
Then I'm not sure what you mean with HTTP-compliant. IMO, HTTP compliancy
is enforced by sending a response according to HTTP specifications for a
specific header.


Yes, that's it. Have a look at the HTTP-RFC, it's a bit more complicated.
There's not only the If-Modified-Since header, but there's also a
If-Match-, If-None-Match-, If-Range-, Vary-, and other headers.
Aug 7 '05 #5
Chris wrote:
Yes, that's it. Have a look at the HTTP-RFC, it's a bit more
complicated. There's not only the If-Modified-Since header, but
there's also a If-Match-, If-None-Match-, If-Range-, Vary-, and other
headers.


I know, I used the if-modified-since header as an example. What you should
do is determine which headers you want to implement support for, implement
them according to specifications and collect them in a class or a set of
functions. Developers tend to write code only for what they need and most
HTTP headers are seldom used on the PHP programming level
JW

..
Aug 7 '05 #6
On Sun, 7 Aug 2005 16:27:15 +0200 Janwillem Borleffs wrote :
I know, I used the if-modified-since header as an example. What you
should do is determine which headers you want to implement support for,
implement them according to specifications


Sure, I could do that. But my question is still, if someone knows a
finished and ready-to-use code.
Aug 7 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: JD | last post by:
I have the below code that displays a small thumbnail if a user is saluted, if they aren't saluted it checks to see if they might have a profile picture, this all works with the exception that is...
11
by: dmbkiwi | last post by:
I am new to this group, and relatively new to python programming, however, have encountered a problem I just cannot solve through reading the documentation, and searching this group on google. I...
4
by: Ryan Lowe | last post by:
i thought id ask here before wirting a PEP, if people thought it would be a good enhancement to allow if clauses in regular for-statements like so: >>> for x in y if x < 10 : is semantically...
303
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b....
6
by: Bart Nessux | last post by:
Should an if statement have a corresponding else statement? Or, is it OK to have an if statement by itself. For completeness, it seems the two should be together, but from experience I know that a...
3
by: Patrice | last post by:
Hi, I need to do multi-conditional statements like below, but this error is displayed : Expected 'End' /myFilepath, line x else response.write(arrCorpo(sparam,sdiv)) end if I don't...
6
by: Oplec | last post by:
Hi, I thought that I understood how C++ allows for the declaration and defining of variables within an if() statement and how the declared variable can be used until the end of the major if()...
5
by: Angelina | last post by:
Hi, I need some help in writing a 'if-then-else' statement. I currently have wrote one that looks something like this.. If Combobox1 = xxx and textbox1 <> "" then 'run stored procedure 1 to...
0
by: John Whitmer | last post by:
I am trying to put together a web page to show remote users which PC's are available for RDP so they can use. The page work's fine except for when the goes to the pc to pull the info on if anybody...
5
by: Steve | last post by:
Hello, I've been a PHP programmer for a number of years and have just started to learn JS. My Employer (a water analysis lab) wants what should be a very simple .js written that basically takes...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.