Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Apr 2009
    Posts
    63
    Thanks
    2
    Thanked 0 Times in 0 Posts

    conditional Get implementation

    1) Project Details: (be as specific as possible): I have deflate compression set up through my Apache server, but I'm unfamiliar with setting up the "conditional GET". Need someone to do the task or walk me through it.

    2) Payment Amount: Not sure. Seems to be a small job. $50?

    3) Payment method/ details (Paypal, check? Timeline?): Paypal

    4) Additional Info (about project or potential bidders): Would like someone very familair with the task.

  • #2
    Banned
    Join Date
    Jun 2007
    Location
    Web Designer
    Posts
    321
    Thanks
    0
    Thanked 6 Times in 6 Posts
    Quote Originally Posted by autotech View Post
    1) Project Details: (be as specific as possible): I have deflate compression set up through my Apache server, but I'm unfamiliar with setting up the "conditional GET". Need someone to do the task or walk me through it.

    2) Payment Amount: Not sure. Seems to be a small job. $50?

    3) Payment method/ details (Paypal, check? Timeline?): Paypal

    4) Additional Info (about project or potential bidders): Would like someone very familair with the task.
    Here is the code for conditionalGet.
    Code:
    function doConditionalGet($timestamp) {
        // A PHP implementation of conditional get, see 
        //   http://fishbowl.pastiche.org/archives/001132.html
        $last_modified = substr(date('r', $timestamp), 0, -5).'GMT';
        $etag = '"'.md5($last_modified).'"';
        // Send the headers
        header("Last-Modified: $last_modified");
        header("ETag: $etag");
        // See if the client has provided the required headers
        $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ?
            stripslashes($_SERVER['HTTP_IF_MODIFIED_SINCE']) :
            false;
        $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ?
            stripslashes($_SERVER['HTTP_IF_NONE_MATCH']) : 
            false;
        if (!$if_modified_since && !$if_none_match) {
            return;
        }
        // At least one of the headers is there - check them
        if ($if_none_match && $if_none_match != $etag) {
            return; // etag is there but doesn't match
        }
        if ($if_modified_since && $if_modified_since != $last_modified) {
            return; // if-modified-since is there but doesn't match
        }
        // Nothing has changed since their last request - serve a 304 and exit
        header('HTTP/1.0 304 Not Modified');
        exit;
    }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •