473,609 Members | 2,222 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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|pn g|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 2203
On Nov 15, 9:48*am, FFMG <FFMG.3iw...@ no-mx.httppoint.co mwrote:
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|pn g|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.c om, (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.co mwrote:
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.c om, (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_conten ts ('/path/to/image.gif');
header ('Content-Type: image/gif');
header ('Content-Length: ' . strlen ($data));
header ('Expires: '. $whatever_expir e_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
4231
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 old image, until I refresh my browser and then zappo, there it is! All changed! I have done everything I can think of to force caching including this: // Date in the past header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
3
7040
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. Obviuosly, the file is fine on the server, so the attachment code I am using must be corrupting it, but I dont know what it is: // send email with attachment function emailAttachment($to, $subject, $message, $name, $email,
1
2076
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 figure out how it specifies the expiry time. Thanks! Hardeep
5
1354
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
10048
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 "Expiry Date" is automatically entered, when the "Production Date" is entered. To do this the "Expiry Date" cell carries the following formula: "=A15+183". I would like to be able to do the same on an Access Form, with the results written to the...
2
3512
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 "Production Date" and the >other is the "Expiry Date". The "Expiry Date" is 183 days after the >"Production Date." > >On an Excel spreadsheet, the "Expiry Date" is automatically entered, when >the "Production Date" is entered. To do this the "Expiry...
3
9200
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 one particular expiry date could have multiple products I am thinking of two approaches not knowing which one to go for. First design is of one product having many expiry dates (a one to many
20
4092
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 server. Basically, I'm writing js errors to an error log on the server side - and there is no need to inform the user that the error has been logged. The problem is that I don't want to sit with the request open & waiting for a response, when I...
1
1860
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 are finally checked. Please help
0
8115
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
8557
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...
1
8205
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6983
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
6047
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
5504
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
4066
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1638
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1374
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.