I have to clear cookies each time I modify css file

拈花ヽ惹草 提交于 2019-12-13 07:06:52

问题


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())}}})();


来源:https://stackoverflow.com/questions/17876633/i-have-to-clear-cookies-each-time-i-modify-css-file

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!