Using PHP to load html page inhibits any attempt at using up to date css file

StackOverflow https://stackoverflow.com/questions/8819914

  •  15-04-2021
  •  | 
  •  

Вопрос

I have user permissions on my .html files other than 0744. They are actually set to 0700 so to get around this, I have suPHP set up, and I use a load.php file to access and load all the files. The file in question is a simple .html file like so:

test.html (0700):

<html>
    <head>
        <link rel="stylesheet" type="text/css" href="test.css" />
    </head>

    <body>
        <p> why is this not working?</p>
    </body>
</html>

test.css (0744):

body
{
    background-color:#bbcbde;
}    
p
{
    background-color:#bfc4de;
    color:'red' ;
    border:'solid black';
    font-size:35pt;
}

load.php (0744):

$page = $_GET['page'];
header("Location: http://www.example.com/" . $fileName);
exit;

Note: the css file I have set to normal 0744 permissions for debugging purposes.

If I type http://www.example.com/load.php?page=test.html the page loads find. However, I suspect that the css file is being used from a cache because none of the changes to test.css are applied to test.html. If I remove the line

<link rel="stylesheet" type="text/css" href="test.css" />

The change is reflected as the background becomes white again. However, if I move the css file to, for example test2.css, and change the style (ie. different colors) and link to that instead, the changes are suprisingly not applied. If I move test.css to test2.css without linking to the new name (similar to deleting the file), the css effect is still applied! Similarly if I chmod test.css to 0000 it still uses the style sheet. Also I know the .css file is not corrupted because I con open up test.html locally on my machine.

Does anyone have any idea what's going on because I don't have the foggiest.

EDIT as per Murray McDonald's answer below, I traced down the problem to having to do with a 304: Not Modified status code. Why Is this being returned when the file has clearly changed?

Это было полезно?

Решение 2

I figured out what my problem (albeit with great support from Murray). I have my folders set up like so

/
├── test
│   ├── test.html
│   └── test.css
├── load.php
└── test.css

I thought that

header("Location: http://www.example.com/" . $fileName);

would launch the page from within the correct folder, but even if I type the following into the browser

http://www.example.com/load.php?page=test/test.html

module.php, when searching for test.css returns /test.css and not /test/test.css which is what I want. Now, the question is how I tell php to set the working directory.

Другие советы

Whenever I run into something mysterious like this I eavesdrop on the HTTP protcol going back and forth between the browser and the server by using "fiddler2" -- it works in MSIE and Firefox. You can easily see the reuest headers the response headers request body, response body (if any) etc.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top