使用 filezilla 或 cpanel 将文件上传到服务器后,css 不起作用
我已使用 filezilla 和 cpanel 将 file.css 文件上传到服务器上。 但是当我浏览网站时,CSS 没有任何影响。
我改变了:padding-left:10px;如果我看到页面视图源,我会看到旧文件在那里。
原因是什么?
I have uploaded the file.css file on server with filezilla and also with cpanel.
But when i browse the website the css has no impact.
I changed: padding-left: 10px; If i see the Page view source i see that the older file is there.
What can be the reason for that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
尝试进行硬刷新。 CTRL Shift R。这将强制清除所有缓存的文件。很可能这就是问题所在,除非文件未上传。如果您看到 Filezilla 中列出了新文件,则表明存在缓存问题。
Try doing a hard refresh. CTRL Shift R. That should force any cached files to clear. Chances are that's the problem, unless the file isn't uploading. If you see the new file listed in Filezilla then it's a cache issue.
你检查过css文件的权限吗?
所有文件应为 644,所有文件夹应为 755。
Have you checked the permission for css files?
It should be 644 for all files, and 755 for all folders.
您是否替换/覆盖了现有的 css 文件?
听起来旧的可能没有被覆盖 - 在这种情况下,您必须这样做才能使更改生效。
您使用的是 CMS 吗?其中一些具有缓存功能,除非硬刷新,否则可能需要一些时间才能反映这些更改。
Did you replace/overwrite the existing css file?
It sounds like maybe the old one wasn't overwritten - in which case you'll have to do that for the changes to take effect.
Are you using a CMS? Some of them have Cache features where it may take time for those changes to be reflected unless you hard refresh.
http://httpd.apache.org/docs/2.2/programs/htcacheclean.html
如果你使用的是 apache2,这太棒了,请使用“-i”选项,文件不更新的原因是它们被缓存了,如果你不能这样做,你可以随时更改 href="styles.css"进入href="styles.css?v=version2" 它使服务器认为有一个新文件,因此它会更新缓存
http://httpd.apache.org/docs/2.2/programs/htcacheclean.html
If you are using apache2 this is amazing, use the "-i" option, the reason the files dont update is because they are cached, if you cant do this you can always change the href="styles.css" into href="styles.css?v=version2" it makes the server think that there is a new file, so then it updates the cache
我更改了 .css 文件的名称,从服务器中删除了旧文件,重新上传并将 html 定向到新命名并上传的 css 文件。由于某种原因,它就像一个魅力。
I changed the name of the .css file, deleted the old one from the server, reuploaded and directed the html to that newly named and uploaded css file. Worked like a charm for some reason.
首先尝试清除缓存。如果没有任何反应,那么像这样链接你的CSS:
它应该有帮助。
First try to clear the cache. If nothing happens then link your CSS like this:
It should help.
如果您使用 nginx,您很可能错误地从 nginx.conf 文件中删除了“include mime.types”指令。所以你应该将其添加回来(下面的代码是从Daniel Peterson):
编辑conf文件并重新加载nginx服务器后,您可能还想通过按ctrl+f5来清理浏览器上的缓存。
If you are using nginx, you very likely have deleted the "include mime.types" directive from your nginx.conf file by mistake. So you should add it back(the code below was copied from Daniel Peterson):
After editing the conf file and reload the nginx server, you may also want to clean the cache on your browser by pressing ctrl+f5.