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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:46:02+00:00 2026-06-03T04:46:02+00:00

I have a page that the user can modify. All modifications are performed using

  • 0

I have a page that the user can modify. All modifications are performed using JQuery, and also sent to the server, so that a full reload will produce the modified page too.

This works fine in Firefox 11 / Chrome on Windows: even if the user navigates somewhere else and then uses the “Back” button, they get the page with their latest edits.

However, if I now embed Google Maps onto the page, the Back button stops working: it takes the user to the page how it was before all their edits. This page doesn’t even exist anymore except in browser’s cache, and yet it gets displayed.

I’ve put together a simple testcase here that shows this behaviour.

What gives? How can I fix this? The perfect solution would just allow the browser to go Back without reloading the page, like it would do normally.

P.S. Apparently the “working” example doesn’t actually work in Chrome on OSX either. How can I work around the browser’s insistence on going back to a stale version of the page?

Bug reports describing this behaviour: Firefox


Bounty: Firefox and Chrome on Windows exhibit both behaviours (going back to the modified DOM in one case, but unmodified in another). Is there a spec describing what the browser should do? Are there bugs filed to change this one way or another? Does this issue have a common name that I can google?

I’m considering a solution whereby I update a hidden element via JavaScript, and then check if the update is still there. If so, the “Back” button restored up-to-date DOM, and nothing else needs to be done. If not, the browser restored outdated DOM, and I can just force a page reload, as unpleasant as that is. Any comments on this approach are also welcome.

Note: the real website has more editable controls than that, and one of them is a freeform text area. I would like the proposed solutions to work even if the user has just added several paragraphs of text. That kind of thing can’t be appended to the URL after the #, for example.

  • 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-03T04:46:03+00:00Added an answer on June 3, 2026 at 4:46 am

    Embedding Google Maps into the page disables the bfcache (I’ll use the Mozilla term for lack of a standard one) because the maps page loaded in an <iframe> uses an unload listener.

    The possible reasons for a page not being cached for fast back navigation in Firefox are listed on MDN: Using Firefox 1.5 caching. Your problem is listed as "the top-level page contains frames that are not cacheable", which is confusing, I’ll try to clarify it later. (Other browsers probably use similar heuristics, since these rules were developed to avoid breaking existing content – see also this answer, it has some links.)

    The correct way to fix this would be to befriend someone at Google and then nag them until they remove the onunload listener at least from maps’ embedded pages.

    In general you shouldn’t ever rely on bfcache working or not working for a particular page. It’s just an optimization for the common case. Since it’s an optimization, it could be disabled, for example when the system is low on memory. It also won’t work if the user restarts the browser before going back, or closes the tab and picks ‘undo close tab’, as you noted in the bug.

    You should either restore the page’s state from JS or mark the page as not cacheable (using an HTTP header). The former results in a better user experience, of course. @Adam Gent’s suggestion looks correct, I’ll have to check what Firefox problem he refers to.


    The reason bfcache works this way is:

    • If the browser runs an onunload handler, then restores the page via bfcache, the page could be broken, since scripts often remove the event listeners in the onunload handler (to "clean up", which is not really necessary except in old IE versions)
    • if the browsers stopped running onunload handlers in a page on the basis that the user might return to the page and they’d like to cache it, the authors would complain.
    • if a page in an iframe can’t be cached, restoring a cached outer page and reloading the inner page would break them sometimes (e.g. if both pages are same-domain, the outer page can hold references to objects in the frame, which won’t be valid after the inner frame is reloaded). So if an iframe is not cached, neither is the parent page.

    The reason the page is still loaded from the (disk) cache when you hit "back" is that presumably you specified that the content you sent to the browser can be cached. The browser has no way to know that you update the page on the server in parallel with making the DOM changes to it.


    [edit]I’ll elaborate on the "mark the page as not cacheable" idea above. To make web browser cache work for, and not against you, it’s important to remember that HTTP is a protocol for retrieving resources. For example, the HTML page identified by the URL http://bbb.akshell.com/broken is a resource. When you serve a resource over HTTP you specify how long the browser’s copy of the resource will be valid (i.e. matching the canonical version of the resource on the server).

    When, as in your testcase, the resource is an HTML page with the item selected by the user marked up in a special way, the resource may change at any time (every time the user changes the selection). This means that the honest HTTP response when serving this resource would be "don’t cache, may change at any time". The browser would then reload the page from the server every time it needs to load the page — correct behavior, but at the cost of slowness for the user.

    An alternative approach, appropriate for things like switching between multiple in-page tabs would be to associate each selection with its own URL. A page with two tabs would correspond to two resources (and two URLs) — one for each tab. Both resources could be (HTTP-)cached by the browser. Changing the URL and the page’s content could be implemented without the roundtrip to the server via pushState.

    Another approach, which seems more applicable to your case, in which you save the user’s input on the server: separate the app UI and the user’s data into different resources (i.e. a static (HTTP-)cacheable HTML page with JS, loading the user data from a separate non-cacheable URL). Request the user data and update the UI on load.[/edit]

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

Sidebar

Related Questions

Imagine that HTML page is a game surface (see picture). User can have n
I have an admin page for a store where a user can modify item
I have hard time to modify a page that had a Custom User Control
I have a Login page that captures User input like this. MD5calc ss =
I have a page that has a bunch of user controls on it. I
I have a complex page that has several user controls like galleries, maps, ads
I have a web page that uses three controls to allow a user to
I have an ASP.NET (3.5) page that allows a user to upload an Excel
I have a dropdown on my master page that lets the user switch language
I have an online store. A products page that allows the user to view

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.