Not serving up-to-date Javascript

December 9, 2018 2.8k views
Ruby Ubuntu

My server is not serving updated JS files; the ones served are not the ones in the code but old ones. I can make changes to HTML okay, but not to JS, so this means the server is responding since I seem some changes.
I added a log to test. Then looking in the network tab, I can see the code of the log is not there. I’ve restarted the app itself as well as Nginx with service nginx restart to no avail (many many times)

I know the reset works because the html will update after restart but the JS will not.

I know this is a Digital Ocean problem because I fixed the app locally and it works. I even deleted the app from the server, and cloned a new version with the changes, booted this up but STILL the problem persists.

It says from memory cache in the dev tools but I don’t know what this means. How do I clear the server cache if such a thing exists? How can this persist across deletion of the app?

5 comments
  • This was a caching issue. I’ve had problems with ruby in the past not updating.

    I cleared the cache several times in the browser before posting this, but clearing again solved this issue. Still, I made another change to test it, cleared the cache (several times) and that change has NOT been reflected. Not sure why changes are not showing.

  • Wouldn’t happen to be using Chrome, would you? If I had a dime for every time I’ve told Chrome to clear cache and it ignored me, I’d definitely have a bag of money sitting around :)

  • I am using Chrome. I’ve never had it ignore me before. Using this exact technology, Sinatra, I always have caching problems but these are cleared up with a cache clear.

    In this case, I am hesitant to touch the app at all since the changes I make are not being reflected. I have other droplets that do not behave like this.

  • Technically the droplet can be related, but not for something being wrong with the droplet itself. It can be that software installed on the droplet is caching the data and actually serving the old content. You can see things like this when using a web server as a reverse proxy with caching enabled, or with caching solutions like memcached, etc.

    To remove the browser from the equation, you can try doing a curl on the file that isn’t updating. You know your terminal isn’t caching, so it’s a pretty sure thing. If it shows the change and the browser doesn’t, it’s related to browser caching. If it doesn’t show the change either, then software on your droplet is caching the content and you need to flush that cache when you make changes.

  • A good debugging idea. Thanks

2 Answers

I have recently got to know about the new Javascript program that has to game me access to the Netgear router login page which is really very helpful. You must always keep it up to date.

Have another answer? Share your knowledge.