Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 553319
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:35:33+00:00 2026-05-13T11:35:33+00:00

My question is about how to reply a HTTP 304 Not Modified when I

  • 0

My question is about how to reply a HTTP 304 “Not Modified” when I receive both if-none-match and if-modified-since from a proxy/client request.

From RFC 2616 secttion 14.26 ( http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.26 ):

If none of the entity tags match, then
the server MAY perform the requested
method as if the If-None-Match header
field did not exist, but MUST also
ignore any If-Modified-Since header
field(s) in the request. That is, if
no entity tags match, then the server
MUST NOT return a 304 (Not Modified)
response.

I am not sure to understand this statement…

  1. “If none of the entity tags match” in PHP do they speak of $_SERVER['HTTP_IF_NONE_MATCH'] vs. my ETags that I sent earlier?
  2. If I understand correctly this statement, as soon as none of the ETags listed in $_SERVER['HTTP_IF_NONE_MATCH'] match my ETags, I stop all verifications and serve the page normally.

Anyone can translate this RFC part in pseudo-code (or PHP code) and/or answer my 2 points above?

EDIT 1:
Thank you St.Woland for your answer. Can you (or anyone else) tell me if I’m correct on these 6 points:

  1. The format of $_SERVER['HTTP_IF_NONE_MATCH'] can be either:

    a)If-None-Match: “xyzzy”, “r2d2xxxx”, “c3piozzzz”

    b) If-None-Match: “xyzzy”

    and NOT:

    c) If-None-Match: “xyzzy, r2d2xxxx, c3piozzzz”

  2. If !array_key_exists('HTTP_IF_NONE_MATCH', $_SERVER), anyTagMatched() returns NULL.

  3. As soon as an ETag in $_SERVER['HTTP_IF_NONE_MATCH'] match my document ETag, anyTagMatched() returns TRUE.

  4. If none of the Etags in $_SERVER['HTTP_IF_NONE_MATCH'] are matching my document ETag, anyTagMatched() returns FALSE.

  5. If $_SERVER['HTTP_IF_MODIFIED_SINCE'] is set and matches my document “last modified” date isExpired() returns FALSE, otherwise return TRUE.

  6. As soon as anyTagMatched() returns TRUE, I issue a 304. If anyTagMatched() returned NULL and isExpired() returned FALSE I can issue a 304. In any other situation I serve my page as normal (I also issue the up-to-date Last-Modified and ETag headers).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:35:33+00:00Added an answer on May 13, 2026 at 11:35 am

    This should be put in the end (moved for better look).

    $anyTagMatched = anyTagMatched() ;
    if( $anyTagMatched || ( ( null === $anyTagMatched ) && !isExpired() ) ) {
        notModified() ;
    }
    // Output content
    

    Pseudocode (review needed):

    <?php
    
    /**
     * Calculates eTag for the current resource.
     */
    function calculateTag() {
    }
    
    /**
     * Gets date of the most recent change.
     */
    function lastChanged() {
    }
    
    /**
     * TRUE if any tag matched
     * FALSE if none matched
     * NULL if header is not specified
     */
    function anyTagMatched() {
        $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ?
            stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : 
            false ;
    
        if( false !== $if_none_match ) {
            $tags = split( ", ", $if_none_match ) ;
            $myTag = calculateTag() ;
            foreach( $tags as $tag ) {
                if( $tag == $myTag ) return true ;
            }
            return false ;
        }
        return null ;
    }
    
    function isExpired() {
        $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ?
            stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) :
            false;
    
        if( false !== $if_modified_since ) {
            // Compare time here; pseudocode.
            return ( $if_modified_since < lastChanged() ) ;
        }
    
        return true ;
    }
    
    function notModified() {
        header('HTTP/1.0 304 Not Modified');
        exit ;
    }
    

    Main answer here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 425k
  • Answers 426k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer os.path.exists() just calls the C library's stat() function. I believe… May 15, 2026 at 12:27 pm
  • Editorial Team
    Editorial Team added an answer You forgot the line splice characters #define ODP ( \… May 15, 2026 at 12:27 pm
  • Editorial Team
    Editorial Team added an answer Jobs are executed in a dynamic module; modules have isolated… May 15, 2026 at 12:27 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.