Flutter web: remained cached after change web version and nginx cache policy is disabled

Viewed 531

I build a flutter web app and deployed it via docker nginx hosting on my local.

flutter build web --pwa-strategy=none  

I added version number in build/web/index.html

  <script src="main.dart.js?version=1" type="application/javascript"></script>

Adding meta Data in our header in index.html:

  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Expires" content="0" />

And in nginx container config :

root@496988ac365e:/# nano /etc/nginx/conf.d/default.conf 

I added these configurations in this path :

server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;

        # kill cache
        sendfile off;
        add_header Last-Modified $date_gmt;
        add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
        if_modified_since off;
        expires off;
        etag off;
    }

Now I deployed a newer version of my pwa and I change src="main.dart.js?version=3", but I still get the old page shown form the first deploy. What is going on !!! How can I disable caching ? I don't want to do clear cache on browser to see new release of web page.

enter image description here

I have a sharedPrefarences so that if user do login for first time for example with by password , for other login don't need to insert password, because I store a flag in sharedPrefarences. But after update version I want to be deleted this sharedPrefarences. But Nothing happen and after changing version it remained .

0 Answers
Related