473,396 Members | 2,026 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,396 software developers and data experts.

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


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).

Nov 15 '08 #1
3 2194
On Nov 15, 9:48*am, FFMG <FFMG.3iw...@no-mx.httppoint.comwrote:
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');
?>
Nov 15 '08 #2

Gordon;201093 Wrote:
>
<?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).

Nov 15 '08 #3
On Nov 15, 12:00*pm, FFMG <FFMG.3ix...@no-mx.httppoint.comwrote:
Gordon;201093 Wrote:
<?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);
?>
Nov 16 '08 #4

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

Similar topics

5
by: Phil Powell | last post by:
I created a page that will be doing image resizing and manipulation, which seems to work (using GD library). However, upon returning to the page where the image has been changed, I still see the...
3
by: Paul Lamonby | last post by:
Hi, I am sending a file from the server as an email attachment. The file is being attached no problem and sending the email, but I get an error when I try to open it saying it is corrupt....
1
by: Hardeep Rakhra | last post by:
Hi i have a snippet of JS that i want to change so that the cookie it creates lasts only 48 hours. (or any other length of time i decide, but 48hours seems right for now) Only thing i can't...
5
by: Maximus | last post by:
Does anyone know how can i send PHP mail? for example, I want to send a HTML email inside it i want to include(somefile.htm);
4
by: William Bradley | last post by:
I have two cells on a form. One of them is the "Production Date" and the other is the "Expiry Date". The "Expiry Date" is 183 days after the "Production Date." On an Excel spreadsheet, the...
2
by: William Bradley | last post by:
"Marshall Barton" <marshbarton@wowway.com> wrote in message news:9as9lvgpnp783kogctb88c8giaepb5uf6g@4ax.com... > William Bradley wrote: > >I have two cells on a form. One of them is the...
3
by: hasanainf | last post by:
Hi all, What will be the best database design for an inventory control that uses expiry date for its products. Over a period of time, a particular product will have many expiry date and that...
20
by: Tony | last post by:
I have a situation where I want to send data, but I have no need for a response. It seems to me that XMLHTTPRequest is the best way to send the data, but I don't need any response back from the...
1
by: Rob Kell | last post by:
I have a vb.net application that emails people daily information. I want to set an expiry for the email so that those who cannot check their emails for a period are not loaded with them when they...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.