PHP页面没有链接更新的css文件

时间:2022-11-22 19:54:52

My CSS is linked in my head tag underneath the title tag like this:

我的CSS链接在标题标签下方的head标签中,如下所示:

<link href="css/main.css" rel="stylesheet">

I was working with the styles yesterday and it was applying the styles well.

昨天我正在使用这些样式,它很好地应用了这些样式。

Today i am adding new styles and they are not working with the PHP file, it still has the css from yesterday when i check the page source even though i have changed the css file.

今天我正在添加新的样式,他们没有使用PHP文件,它仍然有昨天当我检查页面源时,即使我已经更改了css文件的CSS。

What has happened?

发生了什么事?

1 个解决方案

#1


Hard reload is the correct fix here (CTRL+R in Chrome, similar in other browsers).

硬重新加载是正确的解决方法(Chrome中的CTRL + R,与其他浏览器类似)。

You can also fix the issue forever by appending your link to the css file with a query variable that changes, say, every day so that browsers will only cache the css file for a day.

您还可以通过将链接附加到css文件并使用每天更改的查询变量来保存问题,以便浏览器只缓存css文件一天。

<link href="css/main.css?date=<?php echo date('Y-m-d'); ?>"> rel="stylesheet">

#1


Hard reload is the correct fix here (CTRL+R in Chrome, similar in other browsers).

硬重新加载是正确的解决方法(Chrome中的CTRL + R,与其他浏览器类似)。

You can also fix the issue forever by appending your link to the css file with a query variable that changes, say, every day so that browsers will only cache the css file for a day.

您还可以通过将链接附加到css文件并使用每天更改的查询变量来保存问题,以便浏览器只缓存css文件一天。

<link href="css/main.css?date=<?php echo date('Y-m-d'); ?>"> rel="stylesheet">