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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:58:15+00:00 2026-06-07T18:58:15+00:00

In our application we have two use cases in which we want to avoid

  • 0

In our application we have two use cases in which we want to avoid retrieving an out-of-date image from the browser cache:

  1. A user changes her profile picture.
  2. A user changes the picture of another users she is allowed to manage (think of a team and their captain).

In the upload view, we don’t have any problem by appending a timestamp to the image URL, as already suggested in other questions (Refresh image after AJAX file upload, Break image caching). For all other views, there might be a problem with that simple approach: we actually want to use the cache where possible, but avoid it, if we know that we have recently updated the image.

In our application, an administrative user uses a userlist which represents users by their user image (I know, this is revolutionary). If she has just changed one of the user images, she wants this list to show the new image. Same for every other time she sees the user’s image.

We cannot add ?timestamp={now} to every image in this user list, because this would destroy the benefit of any caching.

Any recommendations for a good approach that uses the cache as much as possible and reloads images that we know we have updated?

  • 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-07T18:58:19+00:00Added an answer on June 7, 2026 at 6:58 pm

    The solution we have chosen for now:

    1. We plan to set appropriate headers for images (see this very good answer)
    2. We store a local list of updated images which is used when rendering the URLs

    Part 2 may need some explanation: Fortunately we use a very good JS framework on the frontend that allows us to define arbitrary methods and use them in templates. Our models have one method that returns the photo URL and this URL is used in every template.

    When uploading a new image, we associate the id with the current time stamp in localStorage:

    window.localStorage['nocache.'+id] = new Date().getTime()
    

    Whenever we request an image path, we look into localStorage to see whether we have to append a timestamp to the URL, otherwise the URL is returned as is.

    Advantages / Improvements

    • Updates the user has triggered herself will be available immediately, not only after the cache expires.
    • All other resources use the cache.
    • We look into localStorage for every image URL we are building. This may be expensive.
    • We always have to go through the model’s method to create a photo URL (from a DRY-perspective good, but we are bound to using the model)

    Code

    The code to generate the URL looks like this

    getPhotoUrl: function() {
        return api.getImageUrl(this.id)
    }
    

    In API (very simplified)

    getImageUrl: function(id) {
        var url = "/prefix/something/user/" + id + "/image";
        // if we have stored a timestamp, add that to the URL
        var noCache = window.localStorage['nocache.'+id];
        if (noCache !== undefined) {
            url += "?" + noCache;
        }
        return url;
    }
    

    The template code remains the same:

    <!-- render via img.src -->
    <img src="<%= user.getPhotoUrl() %>" alt="<%= user.lastname %>" />
    
    <!-- render via CSS background -->
    <div class="img" alt="<%= this.shortUsername %>"
        style="background-image: url('<%= this.getPhotoUrl() %>')">
        ...
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So we're scaling out our application to have two Web servers, and will most
We have two tables in our application that both have a ShowOrder column. We
I have a ADO.NET/TSQL performance question. We have two options in our application: 1)
in our application we have a Java applet running inside a .NET browser control.
In our ColdFusion application we have stateless model objects. All the data I want
In our application we have a Queue which is defined as the following: private
We have two TFS build servers (build controllers) available for our application. Builds are
We have an WCF application which uses NHibernate to query data from the database.
In our application we use the repository pattern to retrieve and persist data from
We've got an EXE which works great for installing our application. However, we have

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.