How does PHP refresh the page when you click the return button of the browser to return to the page?

Source: Internet
Author: User
I searched for asp php on the internet. how can I block the cache of the backend button? I searched for asp php on the internet. how can I block the cache of the backend button?

Reply content:

I searched for asp php on the internet. how can I block the cache of the backend button?

  1. Cannot stop browsinghistory.back()And other behaviors

  2. You can set the page to non-cache.

    $nocache = array(    'Expires' => '0',    'Cache-Control' => 'no-store,private, post-check=0, pre-check=0, max-age=0',    'Pragma' => 'no-cache');foreach($nocache as k => $v)    header($k.': '.$v);
  3. If you really want to reject the rollback, you can use the following method to simulate and consider performing a jump.Back onceWill automatically jump to the current page, similar to refreshing

    header('Location: index.php');

Take the homepage pagination link for example:
3
Search engine crawlers access the service based on href./index.php?page=3It is helpful for SEO to obtain 3rd pages of data.
The user can access/index. php normally by right-clicking in the browser and selecting "open in new tab? Page = 3.
If you click a link on the page, the click event is triggered. JS loads and renders local data through AJAX and sets location. hash/index.php#/page/3.
location.hash = "#/page/3";
The browser can automatically remember the location. hash history. we only need to listen to the location. hash change events.hashchange(IE8 is supported, and IE7/6 is not supported). you can reload the page when you click the return button of the browser.

$ (Window ). on ("hashchange", function () {alert (location. hash); // output #/page/2 var arr = location. hash. split ("/"); // ["#", "page", "2"] if (arr [1] = "page ") {page (arr [2]); // AJAX partial loading of 2nd page data // location. href = "/index. php? Page = "+ arr [2] +" & "+ new Date (). getTime (); // directly access page 2nd }});

The above "SEO and experience-oriented hyperlink design" should be able to meet the requirements of the landlord, but it requires a certain amount of transformation costs.

Page loading complete js refresh page location. href = location. href

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.