PHP and Browser 'Back' button - what is really hapenning

前端 未结 2 601
说谎
说谎 2020-12-12 04:58

Assuming my PHP page does \'REAL\' actions.
By \'REAL\' I mean, executing DB actions, writing files, stuff like that, as opposed to just sending HTML.

When I hit

2条回答
  •  执笔经年
    2020-12-12 05:28

    By 'REAL' I mean, executing DB actions....

    ....Assuming it is a GET.

    Then you've already undermined a fundamental principle of HTTP: Get is idempotent, onlu POST, DELE and PUT should modify state at the server.

    There's a very good reason for this; use of the browser navigation elements (back, forward) does not require the browser to refer back to the origin for a GET or HEAD operation even if you tell the browser the page is uncacheable.

    If I have an image I would like to refresh every time

    ...then fetch the image using javascript with a randomly generated query string via the window.onload method.

提交回复
热议问题