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

PHP image generation & caching

Hello,

I hope you can help - I'm a bit new to PHP.

My basic problem is with a page (HTML) which is intended to display an
image slideshow. On this page there are a number of links to click
(one for each slideshow topic) and a "TV screen" to view the results.

The images are stored on the server as (big) JPG files - and when they
are downloaded for the slideshow, I resize them with a PHP script
"im.php" :

$filename = $_GET['filename'];
header('Content-type: image/jpeg');
..
..... open $filename & do the resizing
..
imagejpeg( ...
After a link is selected, I preload the set of images with Javascript
by doing :

im[i].src = "php/im.php?filename=" + getFName(i); // for each in the
set

where getFname(i) returns the i'th image in the set.

I then start the slideshow (I've got things in the Javascript to make
sure all images are preloaded before starting)

Now, my problem is that the browser doesn't seem to be caching the
images and keeps making server requests during the slidehow (which
rather defeats the idea of pre-loading)

If I "cheat" and replace the preloading with :

im[i] = getFName(i);

it works fine (i.e I can switch the server off & it continues to show
the slideshow).

This happens with all browsers I've tried (IE6, Firefox, Netscape)

Hope all this makes sense & would appreciate your expert advice.

Mr WZ Boson
Jul 17 '05 #1
6 2599
Mr WZ Boson <WZ******@yahoo.co.uk> wrote:
This happens with all browsers I've tried (IE6, Firefox, Netscape)

Hope all this makes sense & would appreciate your expert advice.


Get a packetsniffer (like ethereal) and study the differences in request
and response headers. Also a working example would be nice so "we" will
not have to code (and maybe do something completly different) to see
what you are actually talking about.
Jul 17 '05 #2
I would also guess that browsers by now have learned not to cache
dynamic pages and when they see im.php?something they will either
detect it as dynamic page or as unknown file type and not cache it
perhaps. When you put the real filename however, they have no problem
saving the .jpg image in their cache. Another thing to look at is if
you disable caching somewhere in your im.php file via header() function
calls or something like that.

Jul 17 '05 #3
URLs with a querystring (i.e., ones that contain a "?") do not get cached by
the browser.

- Robert
Jul 17 '05 #4
Robert Tweed wrote:
URLs with a querystring (i.e., ones that contain a "?") do not get cached by
the browser.


That depends on the caching directives. Responses to such
requests are cacheable if they include explicit expiration
times. See HTTP/1.1 sec. 13.9.

http://www.ietf.org/rfc/rfc2616.txt

--
Jock
Jul 17 '05 #5
"Mr WZ Boson" <WZ******@yahoo.co.uk> wrote in message
news:c1**************************@posting.google.c om...
Hello,

I hope you can help - I'm a bit new to PHP.

My basic problem is with a page (HTML) which is intended to display an
image slideshow. On this page there are a number of links to click
(one for each slideshow topic) and a "TV screen" to view the results.

The images are stored on the server as (big) JPG files - and when they
are downloaded for the slideshow, I resize them with a PHP script
"im.php" :

$filename = $_GET['filename'];
header('Content-type: image/jpeg');
.
.... open $filename & do the resizing
.
imagejpeg( ...
After a link is selected, I preload the set of images with Javascript
by doing :

im[i].src = "php/im.php?filename=" + getFName(i); // for each in the
set

where getFname(i) returns the i'th image in the set.

I then start the slideshow (I've got things in the Javascript to make
sure all images are preloaded before starting)

Now, my problem is that the browser doesn't seem to be caching the
images and keeps making server requests during the slidehow (which
rather defeats the idea of pre-loading)

If I "cheat" and replace the preloading with :

im[i] = getFName(i);

it works fine (i.e I can switch the server off & it continues to show
the slideshow).

This happens with all browsers I've tried (IE6, Firefox, Netscape)

Hope all this makes sense & would appreciate your expert advice.

Mr WZ Boson


Well, if you want the browser to cache the images, then the images really
aren't dynamic now, are they? So why border serving them dynamically using a
PHP script? I mean you are making your server process the same image over
and over again. Just save the smaller versions of the images in a separate
folder and let the web server handle them.
Jul 17 '05 #6
true, yet not always applicable. What if he changes the images very
often? It's much easier just to drop the new images in, rather than
making two copies of each image, etc. :) After all that's what
computers are for - to do the dirty and repetative job for us.
Of course on the other hand he can have a script to do the resizing
also automatically ... but that "if" situations are endless :)

Jul 17 '05 #7

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

Similar topics

13
by: Mattias Campe | last post by:
Hi, Depending on if I get an image or a text of a certain URL, I want to do something different. I don't know in advance whether I'll get an image or a text. This is a URL that returns an...
2
by: Mike Sobeiski | last post by:
Hi There! I'm developing a web project that requires to produce charts off the database and output it as image and presented to the user in a HTML document. (NOTE: Image is not directly...
7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
4
by: Jake | last post by:
Does cookieless session state (with the sessionid embedded into the url) interfere with the browser's retrieval of cached images from one session to the next? Does the sessionid embedded into the...
1
by: Giggle Girl | last post by:
Hello, I am helping to design a web application that uses 167 little icons on various pages in a framed environment. As is, the app loads each icon on a page by page basis, and if an image...
9
by: Mark Denardo | last post by:
This is related to another post I submitted, but I'll be more precise this time. I have a web page that contains an Image webcontrol that loads its image by: Image1.ImageUrl="<username>.jpg",...
0
by: Cliff Smith | last post by:
Hi Group, In doing a website for a stamp maker, I have come across the following problem. I have a file called image_generator.php that creates a preview of the stamp. This uses GET vars for...
3
by: computer_guy | last post by:
Hi Everyone, I run into a problem. I am trying to write an aspx that can dynamically generate an image based on some input parameters. Things are very simple if the size of the parameters is...
6
by: googletired | last post by:
Hello, I haven't made a XSL in quite sometime so i am very rusty. Basicly i want the XSL to display a defined image if one is not present in the XML. here is my current XSL and XML will be...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.