[Trac] Serving image files and Apache cache issue

Emmanuel-G BLOT emmanuel.blot-gnb at st.com
Fri Jun 3 11:01:45 EDT 2005


I'm facing a weird issue (trac/trunk [1756]):

When Firefox requests a Wiki page with 'embedded' images (which are attached to the same wiki 
page or any other wiki page), Firefox displays the image every other request:

Every time I refresh the page, the image is either displayed or does not appear (i.e. appears a 
text line, the "alt" description), in a flip flop manner every time I refresh the page !

The trouble does not occur with IE client.
The trouble occurs with Apache 2.0.54 running on Win XP1 w/ SSPI authentication, and Apache 
2.0.53 running Linux 2.4 Debian w/ LDAP authentication - I dont think authentication is in 
trouble, as FILE_VIEW is available to anonymous user anyway.

The trouble does not occur with Firefox and tracd standalone server.

I've added a tcpproxy between the client and the server, so that I can dump the whole HTTP 
stream exchanged between them.

Here is a trace (see below) when the error occur.

Firefox request the image in raw format:
GET /trac/nomadik/attachment/wiki/PlayPenAreaManu/bannergalicia.jpg?format=raw HTTP/1.1

but trac's response is the HTML page (as without ?format=raw)
HTTP/1.1 200 OK
...
<!DOCTYPE html
...
HTML preview not available</strong>. To view the file,
    <a href="">download the file</a>

The client request does not seem bad, doesn't it ?

It seems that the only difference between a working request and a failing request is the cache 
information sent by the browser:

If the following line are added to the HTTP header:

If-Modified-Since: Wed, 2 Jun 2005 13:28:59 GMT
Cache-Control: max-age=0

then the server replies with the HTML page, instead of the PNG or JPG image.

When these headers are not sent by the browser, the image is served as expected.

Is there a way to alter the cache settings in Trac, or ... ?

Thanks,
Manu


--- CLIENT [2024] 16:28:58.405280 (583):
GET /trac/nomadik/attachment/wiki/PlayPenAreaManu/bannergalicia.jpg?format=raw HTTP/1.1
Host: localhost:8080
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Accept: image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
Referer: http://localhost:8080/trac/nomadik/wiki/PlayPenAreaManu
Cookie: trac_session=ce57c31e9c2fb926781b069b
If-Modified-Since: Wed, 2 Jun 2005 13:28:59 GMT
Cache-Control: max-age=0

--- SERVER [2024] 16:28:58.418280 (3130):
HTTP/1.1 200 OK
Date: Fri, 03 Jun 2005 14:28:58 GMT
Server: Apache/2.0.54 (Win32) DAV/2 mod_python/3.1.3 Python/2.3.4 SVN/1.2.0 mod_auth_sspi/1.0.1
Cache-control: must-revalidate
Expires: Fri, 01 Jan 1999 00:00:00 GMT
Content-Length: 2787
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Content-Type: text/html;charset=utf-8


<!DOCTYPE html
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
  <title>Nomadik - Trac</title><link rel="start" href="/trac/nomadik/wiki" /><link rel="search" 
href="/trac/nomadik/search" /><link rel="help" href="/trac/nomadik/wiki/TracGuide" /><link 
rel="stylesheet" href="/trac/css/trac.css" type="text/css" /><link rel="stylesheet" 
href="/trac/css/code.css" type="text/css" /><link rel="icon" href="/trac/nk.ico" 
type="image/x-icon" /><link rel="shortcut icon" href="/trac/nk.ico" type="image/x-icon" /><style 
type="text/css">
</style>
  <script src="/trac/js/trac.js" type="text/javascript"></script>
</head>
<body>


<div id="banner">

<div id="header"><a id="logo" href="http://mpuweb.gnb.st.com/"><img src="/trac/nk_banner.png" 
width="167" height="55" alt="Nomadik" /></a><hr />
</div>

<form id="search" action="/trac/nomadik/search" method="get">
  <div>
   <label for="proj-search">Search:</label>
   <input type="text" id="proj-search" name="q" size="10" value="" />
   <input type="submit" value="Search" />
   <input type="hidden" name="wiki" value="on" />
   <input type="hidden" name="changeset" value="on" />
   <input type="hidden" name="ticket" value="on" />
  </div>
</form>



<div id="metanav" class="nav"><ul><li class="first"><a 
href="/trac/nomadik/login">Login</a></li><li><a 
href="/trac/nomadik/settings">Settings</a></li><li><a href="/trac/nomadik/wiki/TracGuide" 
accesskey="6">Help/Guide</a></li><li class="last"><a href="/trac/nomadik/about" 
accesskey="9">About Trac</a></li></ul></div>
</div>

<div id="mainnav" class="nav"><ul><li class="active first"><a href="/trac/nomadik/wiki" 
accesskey="1">Wiki</a></li><li><a href="/trac/nomadik/timeline" 
accesskey="2">Timeline</a></li><li><a href="/trac/nomadik/report">View Tickets</a></li><li 
class="last"><a href="/trac/nomadik/search" accesskey="4">Search</a></li></ul></div>
<div id="main">




<div id="ctxtnav" class="nav"></div>

<div id="content" class="attachment">


  <h1><a href=""></a>: </h1>
  <div id="preview">
    <strong>HTML preview not available</strong>. To view the file,
    <a href="">download the file</a>.
  </div>



</div>
<script type="text/javascript">searchHighlight()</script>

</div>

<div id="footer">
  <hr />
  <a id="tracpowered" href="http://trac.edgewall.com/"><img src="/trac/trac_logo_mini.png" 
height="30" width="107" alt="Trac Powered"/></a>
  <p class="left">
   Powered by <a href="/trac/nomadik/about"><strong>Trac 0.9.pre</strong></a><br />
   By <a href="http://www.edgewall.com/">Edgewall Software</a>.
  </p>
  <p class="right">
   Official web site at<br /><a href="http://mpuweb.gnb.st.com/">http://mpuweb.gnb.st.com/</a>
  </p>
</div>



  </body>
</html>



More information about the Trac mailing list