Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7752487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:48:47+00:00 2026-06-01T11:48:47+00:00

I have a small dynamic site implemented in mod_python . I inherited this, and

  • 0

I have a small dynamic site implemented in mod_python. I inherited this, and while I have successfully made relatively minor changes to its content and logic, with HTTP caching I’m out of my depth. The site works fine already, so this isn’t “the usual question” about how to disable caching for a dynamic site.

My problem is there is one large banner image on each page (the same image from same URL on each page) which accounts for ~90% of site bandwidth but which so far as I can tell isn’t being cached; as I browse the site every time I click to a new page (or back to a previously visited one) there it is downloading it yet again.

If I wget the banner’s image URL (to see the headers) I see:

$ wget -S http://example.com/site/gif?name=banner.gif
--2012-04-04 23:02:38--  http://example.com/site/gif?name=banner.gif
Resolving example.com... 127.0.0.1
Connecting to example.com|127.0.0.1|:80... connected.
HTTP request sent, awaiting response... 
  HTTP/1.1 200 OK
  Date: Wed, 04 Apr 2012 22:02:38 GMT
  Server: Apache/2.2.14 (Ubuntu)
  Content-Location: gif.py
  Vary: negotiate
  TCN: choice
  Set-Cookie: <blah blah blah>
  Connection: close
  Content-Type: image/gif
Length: unspecified [image/gif]
Saving to: `gif?name=banner.gif'

and the code which is serving it up isn’t much more than

    req.content_type = 'image/gif'
    req.sendfile(fullname)

where fullname is a file-path munged from the request’s name parameter.

My question is: is there some quick fix along the lines of setting an Expires: or Vary: field in the image’s request response which will result in clients being less keen to repeatedly download it ?

The site is hosted on Ubuntu 10.04 and doesn’t have any non-default apache mods enabled other than rewrite.

I note that most (not all) of the site pages’ headers themselves do contain

Pragma: no-cache
Cache-Control: no-cache
Expires: -1
Vary: Accept-Encoding

(and the original site author has clearly thought about this as no-cache is applied selectively to non-static content pages). I don’t know enough about caching to know whether this somehow poisons the included .gif IMG into being reloaded every time too though.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:48:48+00:00Added an answer on June 1, 2026 at 11:48 am

    I don’t know if my answer can help you or not, but I post it anyway.
    Instead of serving image files from within python application, you can create another virtualhost within apache (on same server) just to serve static and image file. In your python application, you can embed image likes this

    <img src="http://img.yoursite.com/banner.gif" alt="banner" />
    

    With separate virtualhost, you can add various header to various content type using mode header, or add another caching layer for your static file.

    Hope this help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small problem. So I have this page that loads dynamic content
I have a website in which the total dynamic content is very small (say
Hello fellow stackies, I'm developing a site and I have a small problem. It's
I have a small Dynamic web project in Eclipse gallileo that references another project.
I have a small confusion in the dynamic memory allocation concept. If we declare
So I have this small application of mine I'm trying to deploy using visual
I have some squarish TextViews (with different dynamic sizes(I don't know them while I'm
I have a small popup window with dynamic contents. Nothing too complex. It has
I have this small testcase: http://jsfiddle.net/sV8js/ You can see that in Chrome (tested on
I have written a small piece of code regarding the dynamic loading of assemblies

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.