Connecting Tech Pros Worldwide Help | Site Map

Sending an expiry header, and then the image...

  #1  
Old November 15th, 2008, 09:55 AM
FFMG
Guest
 
Posts: n/a

Hi,

I want to send expiry headers along with my images.

This is the code in my .htaccess file

Code:
--------------------

...
#
RewriteCond $1 \.(gif|jpe?g|png|css|js|ico)$

# if the above request matches then go and get it
RewriteRule ^(.*) - [L,NC,QSA]
...

--------------------


But as well as sending the image out I would like to send an expiry
headers.
So I could change the query to something like...


Code:
--------------------

RewriteRule ^(.*) /myheader.php?r=$1 [L,NC,QSA]

--------------------


where my page 'myheader.php' would send the headers and then the image
out.

I know how to send headers, but i don't know of a php function to
'echo' the image/css.

Or maybe there is an other way, how would you send headers as well as
the image?

Many thanks

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=41186

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

  #2  
Old November 15th, 2008, 11:15 AM
Gordon
Guest
 
Posts: n/a

re: Sending an expiry header, and then the image...


On Nov 15, 9:48*am, FFMG <FFMG.3iw...@no-mx.httppoint.comwrote:
Quote:
Hi,
>
I want to send expiry headers along with my images.
>
This is the code in my .htaccess file
>
Code:
--------------------
>
* ...
* #
* RewriteCond $1 \.(gif|jpe?g|png|css|js|ico)$
>
* # if the above request matches then go and get it
* RewriteRule *^(.*) - [L,NC,QSA]
* ...
>
--------------------
>
But as well as sending the image out I would like to send an expiry
headers.
So I could change the query to something like...
>
Code:
--------------------
>
* RewriteRule ^(.*) /myheader.php?r=$1 [L,NC,QSA]
>
--------------------
>
where my page 'myheader.php' would send the headers and then the image
out.
>
I know how to send headers, but i don't know of a php function to
'echo' the image/css.
>
Or maybe there is an other way, how would you send headers as well as
the image?
>
Many thanks
>
FFMG
>
--
>
'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile:http://www.httppoint.com/member.php?userid=580
View this thread:http://www.httppoint.com/showthread.php?t=41186
>
Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).
<?php
header ('X-My-Header: myValue');
readfile ('/path/to/image.gif');
?>
  #3  
Old November 15th, 2008, 12:05 PM
FFMG
Guest
 
Posts: n/a

re: Sending an expiry header, and then the image...



Gordon;201093 Wrote:
Quote:
>
<?php
header ('X-My-Header: myValue');
readfile ('/path/to/image.gif');
?>
Thanks, do I need to send a special header with the image file?

What I mean is, would doing:

Code:
--------------------

<?php
readfile ('/path/to/image.gif');
?>

--------------------


And nothing else, be exactly the same as opening the file directly?

FFMG


--

'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile: http://www.httppoint.com/member.php?userid=580
View this thread: http://www.httppoint.com/showthread.php?t=41186

Message Posted via the webmaster forum http://www.httppoint.com, (Ad revenue sharing).

  #4  
Old November 16th, 2008, 08:15 AM
Gordon
Guest
 
Posts: n/a

re: Sending an expiry header, and then the image...


On Nov 15, 12:00*pm, FFMG <FFMG.3ix...@no-mx.httppoint.comwrote:
Quote:
Gordon;201093 Wrote:
>
>
>
Quote:
<?php
header ('X-My-Header: myValue');
readfile ('/path/to/image.gif');
?>
>
Thanks, do I need to send a special header with the image file?
>
What I mean is, would doing:
>
Code:
--------------------
>
* <?php
* readfile ('/path/to/image.gif');
* ?>
>
--------------------
>
And nothing else, be exactly the same as opening the file directly?
>
FFMG
>
--
>
'webmaster forum' (http://www.httppoint.com) | 'Free Blogs'
(http://www.journalhome.com/) | 'webmaster Directory'
(http://www.webhostshunter.com/)
'Recreation Vehicle insurance'
(http://www.insurance-owl.com/other/car_rec.php) | 'Free URL
redirection service' (http://urlkick.com/)
------------------------------------------------------------------------
FFMG's Profile:http://www.httppoint.com/member.php?userid=580
View this thread:http://www.httppoint.com/showthread.php?t=41186
>
Message Posted via the webmaster forumhttp://www.httppoint.com, (Ad revenue sharing).
In my experience it has been, if you know the MIME type of the image
sending that wouldn't hurt. Ditto for the filesize, as it will allow
the client to make a time left estimate on how long it will take to
download. Sending the filesize can be done with a slightly different
approach.

<?php
$data = file_get_contents ('/path/to/image.gif');
header ('Content-Type: image/gif');
header ('Content-Length: ' . strlen ($data));
header ('Expires: '. $whatever_expire_value_i_want);
echo ($data);
?>
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Preload images CK answers 2 June 27th, 2008 08:09 PM