shiny css not refreshing after updates

This is a weird problem and I feel it's hard to create a reproducible example. I'm trying to describe the problem here and let the experts to see if this is possible.

I have some styles defined in styles.css, placed in www folder under my shiny app. I included the css with
tags$head(tags$link(rel = "stylesheet", type = "text/css", href = "styles.css")).

Recently I found after I updated the css it didn't take effect in the shiny app. If I inspect the app html source, open the linked http://127.0.0.1:6132/styles.css it will open the old version. I double checked again and again that I was editing the right css file. However somehow an older version css file is cached somewhere and always was loaded.

Is this possible?

1 Like

I have seen things like this with respect to old data appearing in the app though I know I have changed it. I always wonder if I am hallucinating. Try running

sudo systemctl restart shiny-server

from the console.

In this scenario I'd be tempted to use curl on the command line to see exactly what headers are being returned:

# curl -I http://127.0.0.1:6287
HTTP/1.1 200 OK
Date: Sat, 31 Aug 2019 13:40:05 GMT
X-UA-Compatible: IE=edge,chrome=1
Content-Type: text/html; charset=UTF-8
Content-Length: 90177

And I'd wonder if this was possibly related to shiny/httpuv static path caching. (But usually in these situations I find that I've been accidentally modifying the wrong file the whole time, so I'd suggest you triple check that before looking for more exotic explanations.)

1 Like

Yes it happened before I was editing the wrong file. Because I knew this can happen so I triple checked in this case.

Once the rstudio browser was seeing old css but opening in chrome used new css. This time chrome was stucked with old one too.

Then I tried another older version rstudio (suspecting some cache file in desktop folder) and it was using new css. I restarted R session in first rstudio and it also worked this time.

I created an issue in github rstudio since I have found out restart R session do solve the problem and it was not I missed something.

Next time if it happens again I will try curl to see what it report.

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.