473,706 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2093
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_ke y_case(apache_r equest_headers( ), CASE_LOWER);
if (isset($request['if-modified-since'])) {
if (filemtime(__FI LE__) > strtotime($requ est['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
2026
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 no profile picture exist it still trys to display a broken image, Im sure it's a simple mistake any help please? <?php if ($commentUser=="Yes") { ?> <img src="../salute/<?php echo $commentUser;
11
97195
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 have written a theme in python for the superkaramba theme engine on kde (see http://netdragon.sourceforge.net - if you are a kde/linux user, it is a great visual applet engine). I have uploaded it to www.kdelook.org for others to download and...
4
2520
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 equivalent to >>> for x in : but is shorter and easier to read. basically, the if works as a filter for
303
17661
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. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
6
2505
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 if statement by itself works just fine. Below is an example: if x >=0: DO SOMETHING Would it be better, or perhaps more complete, written like this:
3
3889
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 understand why this 'Expected 'End'' error is called! Here is my code: <%
6
2574
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() block. if (int a = /*...*/) { // ... } else if (a = /*variable a be assigned*/) {
5
1757
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 obtain the relevant records and place them in a datagrid. elseif combox1 = yyy and textbox2 <> "" or textbox3 <> "" then
0
4288
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 is logged in or not it seems to have trouble. here is the blurb from the temp file that gets created on the webserver. "Error opening Terminal server Computer-01 Error :Access is denied." The webserver Anon account is using a Domain account that...
5
1871
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 sample hold time data from EPA regulations and spits out when a sample would expire, so we can properly label the thing. The problem is that the .js I have written appears to be doing something unexpected. The Analysis options are presented as...
0
8779
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8695
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9282
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8987
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7900
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6614
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5937
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4708
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3142
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.