简体   繁体   中英

Caching js files in browser

I'm using FastApi (uvicorn) and store js files in static folder, but when i changed js files browsers show me old version.

app.mount("/static", StaticFiles(directory="static"), name="static")

I tried clear browser cache (Chrome, edge, firefox) but result is same

We add an unused query string variable to the url for the js file and set it to a value based on time. For example in an aspx file we use the query string, sn as follows...

writer.Write("<script type='text/javascript' language='JavaScript' src='JavaScript/ClientDiagnostics.js?sn=" + DateTime.Now.Ticks.ToString() + "'></script>");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM