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 5933469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:58:39+00:00 2026-05-22T14:58:39+00:00

I am setting far-future expires headers for my CSS/Javascript so that the browsers don’t

  • 0

I am setting far-future expires headers for my CSS/Javascript so that the browsers don’t ever ask for the files again once they get cached. I also have a simple versioning mechanism so that if the files change, the clients will know.

Basically I have a template tag and I do something like

<script type="text/javascript" src="{{ MEDIA_URL }}{% versioned "javascript/c/c.js" %}"></script>

which will become

<script type="text/javascript" src="http://x.com/media/javascript/c/c.min.js?123456"></script>.

The template tag opens a file javascript/c/c.js.v where it finds the version number and appends it to the query string. The version is generated by a shell script (run manually for now, will probably add pre-commit hook) which checks whether the file has changed (using git diff).

This is all working fine, EXCEPT:

I want to implement the same kind of versioning for images as well. But images can be referenced from CSS – which is a static file (served by nginx) – so no template tag there.

What is a better approach for file versioning?

Alternatively, I am thinking about replacing the template tag with a middleware which changes all links before returning the response. That is better than the template tag, which can be mistakenly omitted. But still doesn’t solve the issue of images referenced from CSS.

Also, I’m aware that having the version as part of the query string might cause trouble with certain proxies not caching the file – so I consider making the version part of the filename – for example javascript/c/c.123456.js.

Note: It looks like there is no way to solve this issue using Django (obviously – since I don’t even serve the CSS through Django). But there has to be a solution, perhaps involving some nginx tricks.

  • 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-05-22T14:58:40+00:00Added an answer on May 22, 2026 at 2:58 pm

    Will add another step to my pre-commit script to replace all direct links with links to versioned files in the minimized CSS.

    Seems there is no better way to do it. If you think of any, let me know and I’ll consider marking that one as accepted answer.

    Thanks for your comments!

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

Sidebar

Related Questions

In IIS7 I am trying to set a really far future expires header for
Today I am going to get as far as I can setting up my
I've been setting up a fresh magento 1.4.0.1 install, working great so far. I
Setting: Java 5 - no upgrade possible. I have a large application that has
I've been tasked with setting up an automated system that will have to do
So I have this issue with setting a margin that dynamical decreases and increases
Why does it seem like Google App Engine isn’t setting appropriate cache-friendly headers (like
So far, I only have a div that would contain this information. As for
I have an activeX control, that ask the user if he want's to install
I've read this article: Setting width of Child View using Percentage So far it

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.