I have to clear cookies each time I modify css fil

2019-08-28 14:18发布

问题:

This is such an annoying and timeconsuming bug!

Since a while back I have to clear the cookies each time I change something in my .css file. Well, currently it's a .less file. But this has happened to me before and also my buddy when working with a .css file.

If I don't clear cookies after a change nothing happens with the site..

Frustrating!

Someone have any good explanation for this strange behavior? :)

Thanks

回答1:

Are you sure your CSS isn't just getting cached by the browser? The next time you modify your CSS file try performing a hard refresh (generally CTRL+F5 on Windows, CMD+SHIFT+R on Mac).



回答2:

I'm not sure that cookies affect your styling but if you have issue with cached css file try adding timestamp to your css file:

<link rel="stylesheet" href="/your/path/to/cssfile.css?{Add a timestamp here}" />

also you can use a bookmarklet(it actually adds timestamp for you):

javascript:void(function(){var i,a,s;a=document.getElementsByTagName('link');for(i=0;i<a.length;i++){s=a[i];if(s.rel.toLowerCase().indexOf('stylesheet')>=0&&s.href) {var h=s.href.replace(/(&|%5C?)forceReload=\d+/,'');s.href=h+(h.indexOf('?')>=0?'&':'?')+'forceReload='+(new Date().valueOf())}}})();