SetInterval() fails in IE

The setInterval timer can be performed normally in Google Chrome, but it will fail under
IE. When using GET to send a request under IE, if the address and parameters of the two requests are the same, the browser will not refresh the page. The content of the first request is cached, and the browser still displays the content of the first time after the server is updated.
For example, if the user logs in on the current page, the user information returned by the server is empty if the user is not logged in, and the user information returned by the request after clicking login is still empty. This is because the browser will cache the GET request.

Usefulness, sending requests regularly to update data in real time.
For example:

   if (tab.index == 2) {
        // console.log(this.$store.state.robot.robot.items.length-1)
        this.timer = setInterval(() => {
          this.$axios
            .get(
              "/api/app/robot/" +
                this.$store.state.robot.robot.items[index].id +
                "/status",
              {
                headers: {
                  Authorization: "Bearer " + sessionStorage.access_token,
                },
              }
            )
            .then((res) => {
          console.log(res.data.bootTime)
            })
            .catch((error) => {
              console.log(error);
            });
        }, 1000);
      } else {
        clearInterval(this.timer);
        this.timer = null;
      }

Under Google: Insert picture description here
Insert picture description here
Under IE
Insert picture description here
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_40648700/article/details/112372604