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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:18:29+00:00 2026-06-07T22:18:29+00:00

If you have a better title for this question feel free to edit. For

  • 0

If you have a better title for this question feel free to edit.

For the longest time, I always used location.reload() to reload the page – it’s the most logical thing to do, right?

But I recently noticed that it is not the equivalent to F5, as I had initially thought, but more of Ctrl+F5. All images and other linked files were re-requested from the server, when all I wanted to do was reload the page.

I discovered that I could use location.replace(location.href) and this appears to achieve the effect I want: reload the page but retrieve linked files from cache.

Is this ideal? Is there a better way than this? Have I overlooked any pitfalls this method may have?

(note: I already have cache-busting management on linked files such as scripts, by appending the filemtime as a query string)

  • 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-07T22:18:31+00:00Added an answer on June 7, 2026 at 10:18 pm

    In answer to my own question, there is a massive pitfall: When the location contains a hash, the browser will jump to that hash instead of reloading the page.

    The solution I implemented is as follows:

    reload = (function() {
        var m = location.search.match(/[?&]__hash=([^&]+)/);
        if( m) location.hash = unescape(m[1]);
        return function() {
                var h = location.hash;
                if( h == "") {
                        location.replace(location.href);
                }
                else {
                        var s = location.search;
                        s = s.replace(/[?&]__hash=[^&]+/,'');
                        s += (s == "" ? "?" : "&")+"__hash="+escape(h);
                        location.replace(location.pathname+s);
                }
        };
    })();
    

    Assuming nothing on the server side uses $_GET['__hash'], this can be used safely.

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

Sidebar

Related Questions

(couldn't think of a better title, feel free to edit it to a title
I really have no idea what to title this so someone PLEASE feel free
I couldn't come up with a better title for this question, so please feel
Feel free to edit the title if you know how to formulate the question
Note: If you think of a better title/question, feel free to suggest it. I
First of all, I have to apologize for not having a better title. Feel
I didn't find a better way to phrase this question in the title. If
Someone please recommend a better title for this question. I'm not sure what to
First of all, my apologies for the title of this question, I don't have
I'm not really sure how to title this question but basically I have an

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.