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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:58:59+00:00 2026-05-20T01:58:59+00:00

I have some javascript code that loads images dynamically in a web page: imageSrc

  • 0

I have some javascript code that loads images dynamically in a web page:

imageSrc = pid.toString() + '/' + imageName + '/' + num.toString();
//imageSrc = pid.toString() + '/' + imageName; 

The first line works fine, but using the second line causes the images to not change after being loaded. I used firebug to capture the headers from the server:

Content-Length  43
Allow   GET, HEAD
Expires Sun, 28 Jan 2007 00:00:00 GMT
Server  CherryPy/3.1.2
Pragma  no-cache
Cache-Control   no-cache, must-revalidate
Date    Sun, 13 Feb 2011 21:12:31 GMT
Content-Type    image/x-png

And I’ve also added the line <meta http-equiv="Cache-control" content="no-cache">
to the head of the web page.

The problem occurs in firefox, IE, and chrome, so I think it must be a fundamental problem, and not a browser issue. Any help would be appreciated.

  • 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-20T01:59:00+00:00Added an answer on May 20, 2026 at 1:59 am

    The typical way to defeat the cache is to append a search string (note the question mark after PNG):

    img.src = path +"/"+ name + ".png?" + (new Date().getTime());
    

    BTW, you don’t need to do .toString(), because the act of adding variables together makes them a string:

    "a" + 1 + 1; // "a11"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a web page in ASP.NET. I have some JavaScript code, and I
I have some jQuery/JavaScript code that I want to run only when there is
I have some code in a javascript file that needs to send queries back
I have some javascript that I'm trying to retool using jQuery to learn the
I have problem in some JavaScript that I am writing where the Switch statement
I have coded some JavaScript to perform an ajax call in an asp.net application.
Like the Delicious submission bookmark-let, I'd like to have some standard JavaScript I can
I have to do some JavaScript in the future, so it is time to
I have some settings I need in a Javascript file -- servers to connect
I want to write some javascript and have it call into the DOM for

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.