Flask cached files, no new changes applied (still loads old .css and .js files) - caching

I have simple flask application running on flask development server on Debian9. Everything worked fine until today. Now, when I change any of the files in static directory, the browser loads the old file and no change is displayed. 2 browsers tried: Chrome and IE.
I've tried this:
Clear all browser cache, refresh page = no effect
Install 2 brand new browsers (Vivaldi and Opera) = On the first time the URL was entered, old .css files were loaded
When I rename the .css file and accordingly modify the html, the changes are applied and everything looks fine until I make another change, then I have to rename it again.
I run flask app with flask run --host='0.0.0.0' --port='80'
I found many similar posts, everytime they were solved by clearing browser cache, or adding #app.after_request decorator, but it did'nt help in this case. I don't think this is browser cache related. Thank you for any advices.

After many desperate hours of trying, I find out, that this behaviour is caused by multiple ssh sessions opened to the server. I had 2 connections via putty, one for starting and stopping server, second for files modifications. I've tested it with opening and closing the second putty connection and it's definitely the cause of the problem. I don't know if this is related only to flask (I'm no linux expert), but maybe it'll help someone.

Related

Drupal twig template doesn't update

I am facing a weird issue.
I changed my theme "activite" template (node--activite.html.twig). This one is mapped with a js script in another file that I map with the libraries.
Until now, everything worked as well.
But, now, all changes I make don't update the template (even a simple <div>test</div>).
What I did :
clear all caches
clear cache in Performances menu
clear cache in database directly
Nothing worked.
There is no server cache and no cache lifetime, no console error.
If I put a console log in a button's template, it's working.
I am on Drupal 8, and I can't change the machine name just for test.
Any advice or solution?
This is solved.
I don't know why (I am not the only who worked on it), the node path had changed. So each time, I was editing the template from an old path....

Codekit 2 not refreshing browser

Codekit 2 does seem to be refreshing in any browsers. I've literally just installed it and been setting it up to my own preferences.
I use my Mac's hosts file to point http://localhost.sites to localhost. I've never had an issue with this in the past (I just set Codekit to refresh on any URL including the word localhost).
Now in the new settings file I'm slightly lost as to where to put it... after a load of mucking about I think I'm in a real state and here are my current settings:
Can anyone shed any light on this? Codekit is not refreshing the browser (all files are compiling fine).
I was having the same issue, #Djave.
Now, while I won't assume you make the same mistakes I do, I found that some errors in my
were causing Chrome to ignore the refresh. Specifically, the closing tag was missing. Instead, I had
<script... />
instead of
</script>
Hope you found the issue on your end.
As Bryan from Incident 57 told me, the refreshing process in Codekit 2 is totally different to the refreshing process in Codekit 1.
Codekit comes with its own server which you are required to run. You can click it in the top right hand corner of the program and it will launch.
You need to have this running to get going. If you have PHP files (or other server side code) Codekit won't run it – so this is where you need your external server running but it is important that you still view the site you're testing at the address given i.e. http://djave.local:5757.
For a far better explanation of all of this you can watch Bryan the creator of Codekit walk you through this in this video here.
https://www.youtube.com/watch?v=YUgH0jlYur0

Magento: updated product's image doesn't appear in frontend

I opened a product, deleted it's images and uploaded other 2 instead. They appeared in backend.
I refreshed the cache, deleted the cache of images in System=>Cache Management. I deleted cache of images in media/catalog/product/cache manually. I deleted the cache in var/cache, deleted the cache in var/minifycache (I have Fooman Speedster), updated indexes in index management. I deleted the cache in my browser.
Finally, the previous images still were present. WTF? I hit all the delete/refresh-buttons again and again, 10 times, I deleted all the possible and impossible caches manually from a file system. Result: the new images didn't appear.
I got very angry after 2 hours of trying.
I deleted those old images from the file system.
The new images did't appear, now I have a default image of Magento for a product.
I tried to access the new images directly (e.g. http://mysite.com/media/catalog/products/o/1.jpg), and the images are loaded and found without problems.
The new images are showed in backend fine.
What the hell is happening? How to get rid of it and, finally, to go bad at 5 a.m.??? Thank everybody for helping me.
My only advice is to double and triple check that you've flush all caches possible (Magento Cache, System Cache, and all 8 caches along with media cache). If you're using Zend Full Page cache, empty that too. Go to /var/cache and delete everything in here and do the same in var/sessions (if you're storing sessions in the file system and not the database).
If all of that fails try using a different browser that you have yet to view the site on. If that fails try uploading a fresh copy of your version of magento, replacing all the core files. I've seen crazy things happen with Magento and a upload of a clean copy fixes problems for whatever reason. Hope this helps!
Just ran into this problem myself. Don't forget to look externally as well, such as in the case of varnish/pagespeed/some CDN, and pay close attention to the URLs. I spent about an hour scratching my head wondering why it wasn't working when I was purging the wrong thing (www.example.com instead of media.example.com).
just try on command
php bin/magento catalog:image:resize
then
reindex command
your system will work perfectly.

CSS file not updating on Azure Deploy/Publish

RESOLVED
Unbeknownst to me, Cloudflare defaults to caching all css/js files for 4 hours.
Scenario:
I add this to our front page:
<span class="test">hullo!</span>
and this to our css file:
.test { font-size:2.0em; }
I do a web deploy, OR full publish to Azure and the span appears on the front page, but not the styling. The css file for some reason does not get updated. FF, IE, Chrome and Safari all confirm it. However, after a seemingly arbitrary time, the css file get updated.
Even when I remote into the Azure VM and restart the app, the styling is unchanged. The app is running on one instance, one role. No Azure Caching is setup. Adding a querystring param to the css file link does not help. Seems like a caching issue but no clue how to resolve.
Any ideas?
"We are using Cloudflare which has a default set up to cache all CSS and JS files. It purges the cache every 4 hours which resulted in the arbitrary updates. So, even though I was adding a new query string to the end of the css file, Cloudflare still cached the old one"
Just a quick note that you should go to CloudFlare Development Mode when making changes to the static content files on your site. You can get to Development Mode to bypass the cache by going to: settings->Development Mode. You also have the option of purging your cache as an additional option, which we would only recommend if you really want to purge everything.
Looks like it's cached by your browser. Can you please try navigate to your site and press Ctrl+F5.
Maybe you can use Fiddler to see if the CSS had been cached, or not updated, or some error when download.
This issue is resolved.
We are using Cloudflare which has a default set up to cache all CSS and JS files. It purges the cache every 4 hours which resulted in the arbitrary updates. So, even though I was adding a new query string to the end of the css file, Cloudflare still cached the old one.
I have dealt with this and I will tell you that from my experience in Chrome you can set a setting that disables the cache in the developer tools, however, I've noticed that unless you have the dev tools window open when you hit Ctrl+F5 it doesn't reload the cache. In IE there is a global setting in the dev tools that will make it redownload everything every time. In Firefox there is also a setting in the dev tools that will require it to download and not use the cache.
One way that you can test this, and how I test this, is by running Fiddler and watching if it does a full download of all your files or if it's caching.
From what I've experienced is that this is truly a browser caching issue and not anything to do with Azure.

CSS reload on IE7

It looks like IE7 doesn't reload the latest version of my stylesheet each time I upload a new version on the server.
This is annoying as I am debugging my .css file to make it work on IE...
Tried to empty the browser cache but still not working.
Thanks for your help.
Ctrl-F5 - forcible way to reload in IE
Include your version number in the file name. myfile_v1234.css
When testing, every time you do an update you can just wite "stylesheet.css?r=98123"
As long as the query string is different, it'll be downloaded again.
If you need, you can use javascript to append Math.random(), to get the random number. Not required on production though, when updates would be stable.
2 Questions:
Does IE eventually load with the newer stylesheet?
How are you saving the changes to the server (SSH, Web Interface, etc.)?
I ask because I ran into an issue with a web-based file management system a while back where one browser would show the CSS just fine, the other wouldn't, and we noticed the issue of which browser played nicely depended on which browser we used to upload the CSS.
The reason turned out to be that IE gave the CSS file a different MIME type than Firefox. If you continue to notice the issue even when you've cleared the cache, check the MIME type of the file using Firefox by going to Tools > Page Info.
Also, if it is simply a caching issue, consider turning caching off in IE. I believe this should be an Advanced Option under Internet Options.
Also, you may want to try creating a special developer environment for IE (if it comes down to it.) Perhaps have another machine with IE7 and no caching and any other features turned off (A kiosk mode, perhaps), and then previewing the page on that machine.
Thanks to you all!
I did manage to solve my problem with the "stupid" Ctrl+F5, and by changing the Internet Parameters of Windows to reload content every new visit.

Resources