I have a problem with cached images...
The script first creates some pictures out of avariable source (every time
the script runs the pics are different):
$im = imagecreatefromjpeg($file);
imagejpeg($im2,"temp100.jpg",100);
imagejpeg($im2,"temp75.jpg",75);
imagejpeg($im2,"temp50.jpg",50);
imagejpeg($im2,"temp25.jpg",25);
then I show them using normal html img tags
<img src="temp100.jpg">
The problem is that the pictures are cached and the script/IE shows a
fautlhy version of the pictures.
I tried messing with the header as described in the php manual.
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
But this doesn't work... wrong pic-fileversion
Does anybody has a sollution?
Thanks
KJ 1 2496
Jaak said the following on 02/01/2006 16:00: I have a problem with cached images...
The script first creates some pictures out of avariable source (every time the script runs the pics are different):
$im = imagecreatefromjpeg($file); imagejpeg($im2,"temp100.jpg",100); imagejpeg($im2,"temp75.jpg",75); imagejpeg($im2,"temp50.jpg",50); imagejpeg($im2,"temp25.jpg",25);
then I show them using normal html img tags
<img src="temp100.jpg">
This is a really bad way of implementing dynamically-generated images.
If more than one user is using your site, then you will get naming
collisions, files overwriting each other, users getting each other's
images, etc.
Much better to have an image-generating script (called, for example,
image.php), e.g.:
image.php
=========
<?php
header("Content-Type: image/jpeg");
/* ... cache-control headers here ... */
/* ... need validation of $_GET fields here ... */
$im = imagecreatefromjpeg($_GET["file"]);
imagejpeg($im, '', $_GET["quality"];
imagedestroy($im);
?>
Then in your HTML, you can call it thus:
<IMG src="image.php?file=file.jpg&quality=50">
The problem is that the pictures are cached and the script/IE shows a fautlhy version of the pictures.
I tried messing with the header as described in the php manual.
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); header("Cache-Control: no-store, no-cache, must-revalidate"); header("Cache-Control: post-check=0, pre-check=0", false); header("Pragma: no-cache");
Where are you putting these headers?
Headers sent with the HTML affect *only* the HTML file, not any embedded
resources (i.e. images).
The solution is to send the appropriate headers with the image files, as
is possible with the image.php implementation above.
--
Oli This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bschollnick |
last post by:
Folks,
I have run into a strange problem, that I have not been able to solve.
I have previously "bundled" this application with Installer
successfully.
Just recently though, I tried, and ran...
|
by: Roland Hall |
last post by:
Scenario:
E-commerce:
User clicks on a button , item is added to cart. User can either
continue shopping or view cart. The order here doesn't matter. When user
views cart, two items are...
|
by: Glenn |
last post by:
Hi,
I have a config XML file that I am using from the application cache. I have configured the entry with a remove callback to re-populate cache automatically when the XML file changes. All is...
|
by: ashish |
last post by:
hi All,
I have a web page which tries to send user a file attachment using
httpresponse, by setting the content-Disposition header..
the problem is that the page is hosted on a ssl site, and...
|
by: Bob Bedford |
last post by:
I've a page where I can upload and delete images.
I've such problem I'm trying to solve. My images are numbered xxxx-1.jpg,
xxxx-2.jpg, xxxx-3.jpg (where xxxx is the article number).
Now, when...
|
by: thehuby |
last post by:
I am building a CMS and as part of it a user can upload an image.
Once uploaded I am displaying the image.
If the user then decides they want to replace the image with another I
get a caching...
|
by: Purti Malhotra |
last post by:
Hi All,
In our Web hosting environment we are using Virtual hosting i.e. multiple
websites are on one server and multiple domains are pointing to a single
website.
Issue: We have two domains...
|
by: Bosnoval |
last post by:
Access 2003 Databse
ASP.NET 2
Win 2003 Server
Currently I have a search page that only allows a single keyword (person) to be searched at a time. I thought upgrading that option via a multiple...
|
by: Harry Haller |
last post by:
What's wrong with this:
Error 3 'System.Web.Caching.Cache' is a 'type', which is not valid
in the given context
public List<AssetSummaryGetAssetSummary()
{
return...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |