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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:24:17+00:00 2026-06-12T23:24:17+00:00

We have a web page which is often reloaded by clicking F5 or Ctrl-R

  • 0

We have a web page which is often reloaded by clicking F5 or Ctrl-R just for sake of looking if some new data arrived.

All images in this page have a cache forever header, so should never be reloaded by the browser.

But when a user presses F5 most browsers check every cache entry with a request and a if-modfied-since header. Our HTML page is never cached anyway but the images should be cached for a long time and there is no need to ask if the image was modified. It is a useless request and we want to get rid of it.

We have a reload icon on our page but users will still use the keyboard to reload (I would rather too).

So I tried to trigger F5 and Ctrl-R keys and do the reload manually like this (btw we are using jquery):

<img src="someimg.png" />
<a id="reload" href="mypage.html">Reload</a>    
<script type="text/javascript">
function loading() {
    window.location.href = $('#reload').attr("href"); 
    return false;
}

function isF5(e) {
    return e.which == 116;
}
function isCtrlR(e) {
    return e.ctrlKey &amp;&amp; e.which == 82;
}

function triggerReloadKeys(e) {
    if (isF5(e) || isCtrlR(e)) {
        $('#reload').click();
    }
}
$(document).bind("keydown", triggerReloadKeys);
$('#reload').click(loading);

someimg.png is always delivered with a long lasting cache directive.

My first answer would be to tell me not taking over the users browser and let him refresh if he wants to. You are right, but we something up to 5000 pages/sec in peak time. And even more images because everybody is reloading the page all the time. We just want to scale down the amount of request, regardless of how fast they are. (and I know that I can’t trigger the browser refresh button in the menu bar, but I don’t care about it right now).

We were pretty successful with reducing the amount of requests in our App as we just don’t have any reload button or F5 but everybody is forced to use our own HTML reload link.

What is possible is to disable the F5 key all together like this:

function triggerReloadKeys(e) {
    if (isF5(e) || isCtrlR(e)) {
        return false;
    }
}

I don’t know if it’s even possible to trigger F5 and force a reload while still using the cache and mimic the behaviour of clicking another link on the page.

Any ideas?

  • 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-12T23:24:18+00:00Added an answer on June 12, 2026 at 11:24 pm

    I assume you did not get your answer yet.

    This is what I am using on my website:

    var ctrlDown = false;
    var ctrlKey = 17, f5Key = 116, rKey = 82;
    
    $(document).keydown(function( e ) {
        if( e.keyCode == f5Key )
        {
            //F5 pressed. Copy your code here or try
            //window.location   = window.location;
            //It will avoid if-modified-since requests.
            e.preventDefault( );
        }
    
        if( e.keyCode == ctrlKey )
            ctrlDown = true;
        if( ctrlDown && ( e.keyCode == rKey ) )
        {
            //Ctrl + R pressed. Do whatever you want
            //or copy the same code here that you did above
            e.preventDefault( );
        }
    
    }).keyup(function(e) {
        if (e.keyCode == ctrlKey)
            ctrlDown = false;
    });
    

    Hope it works for you.

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

Sidebar

Related Questions

I have a web page which reloads some data using a jquery post every
I have a Webforms, AJAX-enabled web page which, when rendering large amounts of data,
I have a web page that displays dynamic data which changes every 2 seconds.
I have a web page with a read-only text box which shows some HTML
I have created a web page which for example contains some links and an
I have web page which is passing a querystring parameter to page 2: <a
I have a web page which uses in PHP and a jQuery DataTable to
I have web page in PHP which displays all records in a table. I
I have a web page in which a fair amount of the content is
I have a web page on which i am applying Ajax enabled update progress

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.