473,327 Members | 1,919 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,327 software developers and data experts.

Dyanmic Images Reload

I have a php script that dynamically creates images, reusing image files on
the server to save space and clutter.

The problem is described in the steps below:

1. User clicks on a button.
2. Same page loads, but the php script creates a new image in an old file.
3. It displays the image file, but the old image shows, even though the file
contains the new image.

My options are:

1. Use javascript to force a reload when the user clicks the button (not
desirable, because the user is forced to confirm the reload by the browser).
2. Put a cheesy blurb on the page telling the user to reload or refresh
(along with ideotic explanations of how to do it).
3. Some really great way someone here is going to describe to me (my
preference).

Rex
Jul 23 '05 #1
4 1870

STEPHEN GOODE wrote:
3. Some really great way someone here is going to describe to me (my
preference).


Add a 'please don't cache me' header to the script creating the image
files. See http://www.php.net/manual/en/function.header.php

NB header() lines must all be issued before any other output is sent to
the browser (but you knew that already). Something along the lines of:

<?php
// a date in the past...
header( "Expires: Sat, 18 Mar 2000 00:00:01 GMT" );
// hint...
header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . " GMT" );
// don't cache me...
header( "Cache-Control: no-cache, must-revalidate" );
// no, really...
header( "Pragma: no-cache" );
// it's a piccy...
header( "Content-type: image/jpeg" );
....
// rest of image code...

?>

---
Steve

Jul 23 '05 #2
Do you need to reload the whole page, or will refreshing the image be
enough?

Maybe just use js to reload only the image.

document.images["imgName"].src="getImage.php?blah="+escape(new
Date());

or something like that. Adding a fake querystring to your image src
will persuade the browser to refetch the image instead of using the
cached version. You might also experiment with adding "no-cache"
headers to your image when you serve it up.

Tim.
"STEPHEN GOODE" <re******@verizon.net> wrote in message
news:oXYxd.3602$hc7.1541@trnddc06...
I have a php script that dynamically creates images, reusing image
files on the server to save space and clutter.

The problem is described in the steps below:

1. User clicks on a button.
2. Same page loads, but the php script creates a new image in an old
file.
3. It displays the image file, but the old image shows, even though
the file contains the new image.

My options are:

1. Use javascript to force a reload when the user clicks the button
(not desirable, because the user is forced to confirm the reload by
the browser).
2. Put a cheesy blurb on the page telling the user to reload or
refresh (along with ideotic explanations of how to do it).
3. Some really great way someone here is going to describe to me (my
preference).

Rex

Jul 23 '05 #3
Steve,

Thanks. I couldn't get it to work. It all seemed to be working. I mean, the
header calls were all done right and before any other output, but it still
cached those images.

What worked was what Tim suggested in another reply. I'm still hoping to
figure out why the headers didn't work.

Thanks again.

Rex
Jul 23 '05 #4
Tim,

Thanks. That worked. Don't know why the no-cache stuff didn't work, but I
plan to figure it out.

Rex
Jul 23 '05 #5

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

Similar topics

4
by: STEPHEN GOODE | last post by:
I have a php script that dynamically creates images, reusing image files on the server to save space and clutter. The problem is described in the steps below: 1. User clicks on a button. 2....
1
by: Winfried Koenig | last post by:
Hi everyone, I have a main page: -------------------------------------------------- <html><head><title>Test</title> </head><body> <img id="img_a" name="img_a" src="image_1.png" alt=""><br>
4
by: Mark Allison | last post by:
Hi, Newbie here, please bear with me. I have a C# project which implements a tree view control. I want to add some images to this tree view control. The tree view control represents the tree...
2
by: JD | last post by:
Hello, I have webcams, and I want to display the images (jpg) from the cameras on a webpage, refreshed continuously. For a smooth transition I found a script that utilises double buffering....
2
tpgames
by: tpgames | last post by:
Me memory game freezes after I click some cards. I seems to be random as to the number of clicks needed before it freezes. I posted the entire code, as I am not sure what is needed for help. I am...
2
by: Hellogeetu | last post by:
Hi All, I am creating dynamic controls but not on page_load event but on one of the button click event. I m able to get the controls value by using request.form but i m unable to handle the...
2
by: RB | last post by:
Hi there, I'm having a problem with an ASP.NET/VB.NET Control I am writing. The control is a simple gallery control, which shows a set of thumbnails (using a DataList), and a main image of the...
1
by: pupilstuff | last post by:
hi guys i wan to make dyanmic crystal report according to values which i checked from check box thats all i did 1. I made data set having data table name "Customer" 2 i put four columm id,name...
30
by: fuchsia555 | last post by:
Is there code to auto reload images if it doesn't load at first time in users browser ?
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.