Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Problem: Side effects of editing a post and going back and forth in navigation history

by LanX (Saint)
on Mar 25, 2022 at 14:51 UTC ( [id://11142416]=monkdiscuss: print w/replies, xml ) Need Help??

Hi

I recently did an edit of a post and afterwards did not only mysterious duplicates appear but also was the newest version of the node replaced by an older edit.

I was able to reproduce the problem by going back and forth in browser history and seeing reloads happening:

compare

I can't tell which phases forced a reload, but I could easily tell that they sometimes happened, because I occasionally saw a very new CB chat while navigating back.

Could this be related to different server configs?

Maybe my test was flawed, but I wanted to document it anyway.

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

  • Comment on Problem: Side effects of editing a post and going back and forth in navigation history

Replies are listed 'Best First'.
Re: Problem: Side effects of editing a post and going back and forth in navigation history
by cavac (Parson) on Mar 29, 2022 at 13:35 UTC

    When doing web development, i often use a chrome extension called "Classic Cache Killer". This helps to make sure that Chrome reloads everything every time you load a page.

    As for browser history: At least in Chrome, it saves a nearly complete copy of the page "as seen" in RAM most of the time. But not all the time. It has some kind of smarts that not always do what you expect. Sometimes it reloads some resources, sometimes it doesn't. From what i understand, the behaviour depends which javascripts are active but also on the headers of the loaded resources and *how* those resources have been loaded. It could also depend on how you left the page you are trying to go back in history.

    For example, the "Vary" header can make a response uncachable. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Vary

    Leaving a page by POSTing a form can also make a page uncachable (or rather "wrong to go back to in history"). This is because POST is assumed to change data on the server, and when you GET a resource, then POST to it, the browser may or may not assume that the history of the previous "GET" request is invalid and try to reload some or all of the resources.

    Basically, going back in time can violate the Idempotency of a chain of requests and that can lead to all sorts of weird and wonderful results. And that may include accidentally ordering the same Amazon shopping cart twice or posting the same reply on Perlmonks a dozen times.

    Idempotent methods in HTTP are GET, HEAD, PUT, DELETE, OPTIONS and TRACE. Although for the browser history to be usable, i guess the methods used in the chain also need to be Safe (GET, HEAD, OPTIONS) and all results cachable.

    So technically, as soon as you use PUT, DELETE, POST, CONNECT or PATCH, everything before that call becomes invalid. If you go back in time to a page before such a call, it is not a usable page in the sense that you can submit a webform and expect it to work correctly.

    As for your case of duplicates appearing, this could simply be a case where you submit a post, then go back in time before submitting the post (not "editing an existing post") and resubmit it again. Meaning the webform still has the "this is a new reply" flag set (or missing the "editing node 12345678" field, whatever).

    perl -e 'use Crypt::Digest::SHA256 qw[sha256_hex]; print substr(sha256_hex("the Answer To Life, The Universe And Everything"), 6, 2), "\n";'
      > . From what i understand, the behaviour depends which javascripts are active but also on the headers of the loaded resources and how those resources have been loaded.

      That's a good point, I have some Nodelet Hacks active, one even registering an onSubmit handler.

      So this might be a private problem. Will try to run some tests after the German Perl Workshop...

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: monkdiscuss [id://11142416]
Approved by davies
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (3)
As of 2024-04-26 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found