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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:28:16+00:00 2026-06-08T23:28:16+00:00

Im using a modified version of Eric Bidelman’s/HTML5Rocks cachebust.py file for css/js. link is

  • 0

Im using a modified version of Eric Bidelman’s/HTML5Rocks cachebust.py file for css/js. link is here

Instead of appending timestamp like

.css?2012-07-30

I modified variable to –

cachebust = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(10))

so it becomes (for example)

.css?6SKD39SFJ3

his original version didnt seem to remove the date either, so im not really sure how that is a ‘cache control’ but i figured if i could just auto-strip those 10 characters, it would work. first targeting any js files (for new files), then if js? (with cachecontrol already in place), strip that existing cachecontrol

asset = re.search('\.(js")><\/script>', line)
if asset is not None:
  existing = re.search('\.(js?"', line)
  if existing is not None:
    line[i] = line.replace('.js?'STRING????'"', '.js"')
  lines[i] = line.replace('.js"></script>', '.js?%s"></script>' % cachebust)

thoughts on what that STRING???? should be, or if this method wouldnt work? im new to python so im just experimenting here…

  • 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-08T23:28:17+00:00Added an answer on June 8, 2026 at 11:28 pm

    You could replace the 3 lines:

    existing = re.search('\.(js?"', line)
    if existing is not None:
        line[i] = line.replace('.js?'STRING????'"', '.js"')
    

    with:

    re.sub(r'\.js\?[-0-9]{10}">',r'.js?">', line)
    

    Output:

    >>> re.sub(r'\.js\?[-0-9]{10}">',r'.js?">', '<script type="blah" src="url/to/path.js?2012-07-02">')
    '<script type="blah" src="url/to/path.js?">'
    

    I have used the regexp [-0-9]{10} which stands for 10 characters of digits and a dash. In case that can stand for any 10 characters, use: .{10}

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

Sidebar

Related Questions

I'm using a slightly modified version of Valum's upload [ github link ], I've
I am using a modified version of the code here . The difference is
~ I am using a very slightly modified version of the jQuery tooltip script
How do you get any file's last modified date using VB6?
I am using a modified version of light house from this page. I want
I'm using a modified version on juno ( http://github.com/breily/juno/ ) in Google App Engine.
I using a vendor modified version Linux which is based on a 2.6.14.* (more
I am running a local instance of HTTP::Daemon using a modified version of the
I'm trying to append rows upon scrolling of a table using a modified version
I am using a slightly modified version of this code . to create a

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.