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

  • Home
  • SEARCH
  • 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 111285
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:21:38+00:00 2026-05-11T02:21:38+00:00

How can I get static content on Apache to be {cached by browser} and

  • 0

How can I get static content on Apache to be {cached by browser} and not {checked for freshness {with every request}}?

I’m working on a website hosted on Apache webserver. Recently, I was testing something with headers (Content-Type for different types of content) and saw a lot of conditional requests for images. Example:

200 /index.php?page=1234&action=list 304 /favicon.ico 304 /img/logo.png 304 /img/arrow.png (etc.) 

Although the image files are static content and are cached by the browser, every time a user opens a page that links to them, they are conditionally requested, to which they send "304 Not Modified". That’s good (less data transferred), but it means 20+ more requests with every page load (longer page load due to all those round-trips, even with Keep-Alive and pipelining enabled).

How do I tell the browser to keep the existing file and not check for newer version?

EDIT: the mod_expires method works, even with the favicon.

  • 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. 2026-05-11T02:21:39+00:00Added an answer on May 11, 2026 at 2:21 am

    Expires module in Apache solves this

    a2enmod expires 

    it needs to be loaded in server config, and set up in .htaccess (or in server config).

    With an Expires header, the resource is only requested the first time. Before the expiration date, subsequent requests are fulfilled from browser cache. After the specified time expires and the resource is needed, only then it is requested again (conditionally – a 304 will be returned for an unchanged resource). The only reliable way to clear it from the cache before it expires is manually, or by forcing a refresh (usually Ctrl-F5). (This could be an issue if the resource changes in the meantime, but statical images don’t change very often.)

    # enable the directives - assuming they're not enabled globally ExpiresActive on  # send an Expires: header for each of these mimetypes (as defined by server) ExpiresByType image/png 'access plus 1 month' ExpiresByType image/gif 'access plus 1 month' ExpiresByType image/jpeg 'access plus 1 month'  # css may change a bit sometimes, so define shorter expiration ExpiresByType text/css 'access plus 1 days' 

    For favicon.ico, a bit more work is needed (Apache normally does not recognize Windows icon files, and sends this as the default text/plain).

    # special MIME type for icons - see http://www.iana.org/assignments/media-types/image/vnd.microsoft.icon AddType image/vnd.microsoft.icon .ico # now we have icon MIME type, we can use it # my favicon doesn't change much ExpiresByType image/vnd.microsoft.icon 'access plus 3 months' 

    And voila, It Works™!

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

Sidebar

Ask A Question

Stats

  • Questions 95k
  • Answers 95k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Custom cell, either on that column or on a second… May 11, 2026 at 7:06 pm
  • Editorial Team
    Editorial Team added an answer This is one of those questions that really belongs on… May 11, 2026 at 7:06 pm
  • Editorial Team
    Editorial Team added an answer You mention Box but it can be used in a… May 11, 2026 at 7:05 pm

Related Questions

Ok, so I want to get a webapp running in tomcat (5.5) to run
Recently, I took it upon myself to try and learn OO programming. It has
I'm trying to create a custom transition, to serve as a replacement for a
I have to interface with a slightly archaic system that doesn't use webservices. In

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.