amphp / amphp/http-server-static-content

Issue with If-Modified-Since HTTP header

Open
#18 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
22
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Hi there 👋🙂
I noticed that when I modify a file served by DocumentRoot, I have to force the refresh in my browser to actually see the updated file.
After some debugging, I think there is an inversion in the order of comparison:
https://github.com/amphp/http-server-static-content/blob/2.x/src/DocumentRoot.php#L304C49-L304C66

The code returns "unmodified" status if $mtime > $ifModifiedSince, but if I understand correctly it's the opposite, if $mtime > $ifModifiedSince it means that the file has been updated. (Corresponding doc for reference)

I'm currently running version 1, but as far as I can see the bug is present on branch 2 as well.
It doesn't seem to be covered by tests.

By the way, thank you very much for your work on this awesome library 😊

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at src/DocumentRoot.php around line 304 and compare the If-Modified-Since handling with the linked HTTP header documentation. Add coverage for a modified DocumentRoot file, then run the relevant test suite; done means updated files are not reported as unmodified while unchanged files still are.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.