Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. How to ensure that the wasm file accessed by users is always the latest after project modifications?
Forum Updated to NodeBB v4.3 + New Features

How to ensure that the wasm file accessed by users is always the latest after project modifications?

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
6 Posts 2 Posters 782 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JasonWongJ Offline
    JasonWongJ Offline
    JasonWong
    wrote on last edited by
    #1

    I am currently using the wasm kit to compile a Qt project, and then I get some static web files, such as xxx.wasm and xxx.js. I deploy these files to my backend server, and everything works fine.

    However, I am now encountering a problem: after modifying the Qt project and recompiling, the new files are not accessed by others in a timely manner due to browser caching. So I am thinking of modifying the dynamic loading logic of the wasm/js files. For example, the current link is https://web.jasonserver.com:10035/JQClock/JQClock.wasm. It can be modified to https://web.jasonserver.com:10035/JQClock/JQClock.wasm?t=123456, and after each compilation, the 123456 at the end can be changed to ensure that users access the latest version. This may require modifying the loading logic in the js file, but the js file is dynamically generated. I want to know how to modify it appropriately.

    1 Reply Last reply
    1
    • JasonWongJ Offline
      JasonWongJ Offline
      JasonWong
      wrote on last edited by
      #2

      Because the caching rules of browsers are quite complex, I tried modifying Cache-Control on the backend server, but this doesn't necessarily work, and it might be a setting issue on my part? However, I haven't found the real cause.

      Therefore, I think if it's possible to modify the loading logic of the wasm files, it might be the most suitable and reliable solution. For example, adding an MD5 hash or a random marker.

      1 Reply Last reply
      0
      • JasonWongJ Offline
        JasonWongJ Offline
        JasonWong
        wrote on last edited by
        #3

        For example, the Webpack tool modifies related files and adds an MD5 hash each time it packages. Can we have similar logic in Qt wasm kit?

        R 1 Reply Last reply
        0
        • JasonWongJ Offline
          JasonWongJ Offline
          JasonWong
          wrote on last edited by
          #4

          This is a screenshot of Chrome. What I mean is to modify this URL.

          chrome.png

          1 Reply Last reply
          0
          • JasonWongJ JasonWong

            For example, the Webpack tool modifies related files and adds an MD5 hash each time it packages. Can we have similar logic in Qt wasm kit?

            R Offline
            R Offline
            RandomGuy
            wrote on last edited by RandomGuy
            #5

            @JasonWong said in How to ensure that the wasm file accessed by users is always the latest after project modifications?:

            For example, the Webpack tool modifies related files and adds an MD5 hash each time it packages. Can we have similar logic in Qt wasm kit?

            That's what I did in my project... I generate a unique UID for the current build when building and save it to text file, this text file is later uploaded to the website. When the user enters the website, the website automatically fetches the latest UID in this text file (make sure you fetch it through POST so you don't get a cached version).

            Then you compare the running UID with the one downloaded, if they match everything is ok, otherwise you ask the user to update the website (or update it automatically) by forcing a POST on the .wasm file (so the browser doesn't fetch the cached .wasm file) and then refresh the webpage; you will end up with the latest version.

            JasonWongJ 1 Reply Last reply
            1
            • R RandomGuy

              @JasonWong said in How to ensure that the wasm file accessed by users is always the latest after project modifications?:

              For example, the Webpack tool modifies related files and adds an MD5 hash each time it packages. Can we have similar logic in Qt wasm kit?

              That's what I did in my project... I generate a unique UID for the current build when building and save it to text file, this text file is later uploaded to the website. When the user enters the website, the website automatically fetches the latest UID in this text file (make sure you fetch it through POST so you don't get a cached version).

              Then you compare the running UID with the one downloaded, if they match everything is ok, otherwise you ask the user to update the website (or update it automatically) by forcing a POST on the .wasm file (so the browser doesn't fetch the cached .wasm file) and then refresh the webpage; you will end up with the latest version.

              JasonWongJ Offline
              JasonWongJ Offline
              JasonWong
              wrote on last edited by
              #6

              @RandomGuy This is a good solution

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved