Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

Can .htaccess test for If-Modified-Since?

Can I use .htaccess to test if a browser sends this to in the header to the server:  
      If-Modified-Since: XXXXXXXXX GMT

and if so redirect the visitor to:
      304.php
?
Avatar of caterham_www
caterham_www
Flag of Germany image

Yes, of course
RewriteEngine on
# check
RewriteCond %{HTTP:If-Modified-Since} ^(.+)
# and pass as query strng q=
RewriteRule !^304\.php$ /304.php?q=%1 [L]

Open in new window

Avatar of hankknight

ASKER

caterham_www, I think you clearly understand what I am trying to do.

If a server has already sent a file or an image I do NOT want to send it again.  Instead I want to tell them to stop wasting time and bandwidth by sending them a 304 header.
https://www.experts-exchange.com/questions/24168325/Send-304-Header-if-cached-Apache.html

Will this work the way I intend it to?  Will it save website visitors time and my server bandwidth?

After giving my last question some thought, do you think it will work about as good as your ideas to modify and  recompiling the mod_rewrite.c module or make a custom Apache module?
<?php
   // 304.php
   header('HTTP/1.1 304 Not Modified');
   exit();
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of caterham_www
caterham_www
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial