Re: [users@httpd] When an image is replaced in the htdocs directory through a cgi script and incorporated into a new html page the new image does not get displayed

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Owen,

You are correct. The browser was caching it.

Thanks, Simon

Boyle Owen wrote:

-----Original Message-----
From: Simon Hook [mailto:simon.j.hook@xxxxxxxxxxxx]
Sent: Donnerstag, 10. März 2005 17:01
To: Boyle Owen
Subject: Re: [users@httpd] When an image is replaced in the htdocs
directory through a cgi script and incorporated into a new html page the
new image does not get displayed


Hi Owen

Please keep on list...

mod_file_cache is disabled:

#LoadModule file_cache_module modules/mod_file_cache.so

I get the same problem with either Firefox or IE so while it could be a browser cache problem it seems like and Apache problem.

This is not convincing. Both these browsers have extensive caching capabilities. In Firefox, you can clear the cache with Tools -> Options -> Privacy -> Cache -> Clear. Do this between requests to eliminate the browser cache.

Also, to investigate further, look in the apache access_log while you request the page. You should see a GET for the HTML page and then another GET for the embedded image. If you don't see a second GET, then the browser is deciding not to request it because it thinks it already has it. If you do see a second GET, look at the response code; if it's 200 then apache fetched the image again, if it's 304 then apache is replying "Not Modified" (which would be bad).
I am not sure what you mean by connected directly to the server. Apache is installed on my machine and I am accessing files with a webrowser on my machine i.e.

http://mymachine/cgin-bin/noupdate.py

so I think I am directly connected to my server.

If both browser and server are running on the same physical machine then you're directly connected :-) If your server had been, say, on a remote hosting location and your browser on a desktop inside a corporate LAN, there would almost certainly have been a caching proxy somewhere in between..

Any other ideas its a complete showstopper for using Apache!

My guess is it is certainly a browser cache problem. You have to convince the browser to re-issue the request no matter what. You could try ExpiresByType (see http://httpd.apache.org/docs-2.0/mod/mod_expires.html#expiresbytype) to do this, eg.

ExpiresByType image/png A0

Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored.
Thanks, Simon

Boyle Owen wrote:



-----Original Message-----
From: Simon Hook [mailto:simon.j.hook@xxxxxxxxxxxx]
Sent: Donnerstag, 10. März 2005 07:23
To: users@xxxxxxxxxxxxxxxx
Subject: [users@httpd] When an image is replaced in the htdocs directory through a cgi script and incorporated into a new html page the new image
does not get incorporated.


PROBLEM: When an image is replaced in the htdocs directory through a cgi script and incorporated into a new html page the new image does not get incorporated.

Hi All,

I am trying to write a web app where a variable, passed with a form, is used to generate a plot, which is saved and then displayed as a static image in an html page. I am using the webform from pythonweb and generating the plot with matplotlib. I am using Apache 2.053 under Windows XP. I am keeping it real simple by simply passing
an integer.
The whole process works, HOWEVER, when I back page and submit a new integer value which generates a new plot and new static image, the new image does not get displayed, instead the last version of
the static
image (plot) is displayed (presumably from the cache).
Rather, "...presumably from *a* cache..."

There are several points where data are cached in a typical
browser-server configuration:

- in the server: Are you using mod_cache? If so, try CacheDisable the
path to the cgi, or just switch off (don't Load it).

- in the network: Are the browser and server connected via a
network? If
there are proxies in the route, they will certainly cache
things.. Can
you connect directly?

- in the browser: disable caching (thought his will make
pages slow to
load - it'll have to reload images every time

To check if it's really the server, use a browser with caching turned
off and connected directly to the server..

Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored.



If I reload the page with the browser the updated image gets displayed
otherwise the
previous plot gets displayed with 2 or 3 re-submits and then eventually an updated one is displayed. It seems like Apache does not recognize a changed image and still uses the first plot I created for 2 or 3 submits or the submit does not force Apache to look for a changed file.

I am new to Apache, Pythonweb and MatplotLib although I have done similar stuff with ASP and IIS and some Python work. I have waded through the Apache and Pythonweb documentation and got nowhere. I have tried using the MOD_EXPIRES directive with Apache but this has no effect. I think this is because a new image (PNG) has been
generated
rather than an old one has expired. I cannot see any way with pythonweb forms to load a static html page (i.e. with cgi). I think
if I had a
static html page I could write out maybe I could expire that which would force Apache to load the new image file.

I have tried

<META HTTP-EQUIV=Refresh CONTENT=1>

which refreshes the page every second - this works but who would want it!

I have tried

<META HTTP-EQUIV=expires CONTENT=0>

but this does not work.

I have attached the code below, its a rework of one of the examples in pythonweb. Just copy this to the cgi-bin directory and it should work, provided matplotlib is installed. Matplotlib is available from:

http://matplotlib.sourceforge.net/

Pythonweb is available from:

http://www.pythonweb.org

Despite hours of trying I cannot get this to work, which would seem like a necessity for Pythonweb and Apache. Any help would be much appreciated.

Thanks,

Simon

---cut here

#!d:/apps/Python23/python

"The form that will not update"

import sys, re, os
sys.path.append('../')
sys.path.append('../../')

import web.error; web.error.handle(handler='browser',
output='debug',
format='html')
import web, web.form, web.form.field.basic, web.util
import web.form.field.typed
from pylab import *
class ExampleForm(web.form.Form):
def setup(self): self.addField(web.form.field.typed.Integer('myval', default=6, required=True)) # The preffered way of adding submit buttons is as
actions so
Submit buttons are normally not used.
      self.addAction('Validate This Form')

# Print the HTTP Header
print web.header('text/html')

# Create a form
exampleForm = ExampleForm('form', os.environ['SCRIPT_NAME'], 'get')

if len(web.cgi) > 0: # Form submitted
  # Populate form with the values from get.
# Populate the form exampleForm.populate(web.cgi) # Process the form (Validate) if exampleForm.valid(): # Grab the desired value, from the form
      myval=exampleForm['myval'].value
# Create the plot, saved as a png in the htdocs directory
      myarray=[myval,4,9,16]
      print myarray
      plot([1,2,3,4], myarray, 'ro')
      axis([0, 6, 0, 20])
      savefig('../htdocs/plot.png')
print "<hmtl><body><div align=center><img src=/plot.png alt=theplot></div></body></html>"

else:
print "<html><head><title>noupdate</title></head><body>\n<h1>Input integer 0-10</h1>%s\n<hr></body></html>"%(exampleForm.html())

---end cut

------------------------------------------------------------
---------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
 "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


Diese E-mail ist eine private und persönliche Kommunikation. Sie hat
keinen Bezug zur Börsen- bzw. Geschäftstätigkeit der SWX Gruppe. This
e-mail is of a private and personal nature. It is not related to the
exchange or business activities of the SWX Group. Le présent
e-mail est
un message privé et personnel, sans rapport avec l'activité
boursière du
Groupe SWX.

This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any
mistransmission.
If you receive this message in error, please notify the
sender urgently
and then immediately delete the message and any copies of it
from your
system. Please also immediately destroy any hardcopies of
the message.
You must not, directly or indirectly, use, disclose,
distribute, print,
or copy any part of this message if you are not the intended
recipient.
The sender's company reserves the right to monitor all e-mail
communications through their networks. Any views expressed in this
message are those of the individual sender, except where the message
states otherwise and the sender is authorised to state them to be the
views of the sender's company.


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP
Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
 "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


--

+++++++++++++++++++++++++++++++++++++++++
Simon J. Hook, MSc, PhD
Jet Propulsion Laboratory MS 183-501
Pasadena, CA 91109
Office: 818-354-0974
Fax: 818-354-0966
Email: simon.j.hook@xxxxxxxxxxxx
http://asterweb.jpl.nasa.gov
http://masterweb.jpl.nasa.gov
http://laketahoe.jpl.nasa.gov
+++++++++++++++++++++++++++++++++++++++++


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx

--

+++++++++++++++++++++++++++++++++++++++++
Simon J. Hook, MSc, PhD
Jet Propulsion Laboratory MS 183-501
Pasadena, CA 91109
Office: 818-354-0974
Fax: 818-354-0966
Email: simon.j.hook@xxxxxxxxxxxx
http://asterweb.jpl.nasa.gov
http://masterweb.jpl.nasa.gov
http://laketahoe.jpl.nasa.gov
+++++++++++++++++++++++++++++++++++++++++

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux