Some users build custom web applications that require checking for a 304 Not Modified header when using CDN. Returning a 304 Response requires adding the headers to the Origin file/URL.
There are a couple of ways to accomplish that, one of them being to manually add the Last Modified header to .htaccess:

    <IfModule mod_expires.c>
    Header set Last-Modified "Mon, 14 Feb 2013 00:00:00 GMT"
    </IfModule>

Note

You will have to choose the day you like, this is just an example.

Another way is to do it in your PHP Script:

    <?php
    $file = "index.php";
    $last_modified_time = filemtime($file);
    $etag = md5_file($file);
    // always send headers
    header("Last-Modified: ".gmdate("D, d M Y H:i:s", $last_modified_time)." GMT");
    header("Etag: $etag");
    // exit if not modified
    if (@strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE']) == $last_modified_time ||
        @trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag) {
        header("HTTP/1.1 304 Not Modified");
        exit;
    }
    ?>

Note

The above code is only an example. You can always try different methods, depends on your application and programming platform.

In order to check, you can look at the response header in Firebug’s NET Tab, or run the following curl command:

$ curl -I --header 'If-Modified-Since: Mon, 14 Feb 2013 00:00:00 GMT' http://cdn.example.com/myfile.png
HTTP/1.1 304 Not Modified
Date: Wed, 14 Feb 2013 13:58:33 GMT
Connection: keep-alive
ETag: LKJou908hjoiulO879kjlhOIUH
Last-Modified: Fri, 08 Feb 2013 02:25:16 GMT
X-Content-Type-Options: nosniff
Expires: Thu, 14 Feb 2013 13:58:32 GMT
Cache-Control: max-age=86400, s-maxage=604800, must-revalidate, proxy-revalidate
Server: NetDNA-cache/2.2
X-Cache: MISS

Note:

304 could be either an X-Cache: HIT or X-Cache: MISS