Note that there are some explanatory texts on larger screens.

plurals
  1. POIs my PHP script cache (public) friendly?
    primarykey
    data
    text
    <p>I have finalized a small PHP application that can serve many documents. These documents <strong>must</strong> be cacheable by clients <strong>and</strong> proxies.</p> <p>Since proxies can cache my results I must be extra careful because the documents I serve can have different MIMEs types (content negotiation based on $_SERVER['HTTP_ACCEPT']) and different languages (based in this order: $_POST value / $_GET value / URL / PHP session value / $_COOKIE value / $_SERVER['HTTP_ACCEPT_LANGUAGE'] / default script value).</p> <p>To shortly sum up, a page can be served with many MIME type <strong>and</strong> many languages with the <strong>same</strong> URL (question changed: see edit below).</p> <p>To help cache on proxies I use the "Vary: Accept" header <strong>in combination</strong> with the ETag header. The ETags is a MD5 of the current language and the last modified timestamp.</p> <p>I always:</p> <ul> <li>Send an Expires header</li> <li>Send a Cache-Control header</li> <li>Send a Last-Modified header</li> <li>Send a Content-Type header</li> <li>Send an ETag header (based on current language and Last-Modified timestamp)</li> <li>Send a Content-Language</li> <li>Send a "Vary: Accept" header if the document is XHTML</li> </ul> <p>Now with my question: is this enough to help cache on proxies <strong>and</strong> clients? Did I miss a thing/header?</p> <p>To help you, here’s the HTTP response header for a test page (on my local environment):</p> <pre><code>" Date Wed, 30 Dec 2009 18:56:26 GMT Server Apache/2.0.63 (Win32) PHP/5.1.0 X-Powered-By PHP/5.1.0 Set-Cookie Tests=697daqbmple2e1daq2dg74ur96; path=/ Expires Wed, 30 Dec 2009 21:56:26 GMT Cache-Control public, max-age=10800 Last-Modified Mon, 28 Dec 2009 15:11:49 GMT Etag "44fa50be4638161a596e4b75d6ab7a94" Vary Accept Content-Language en-us Content-Length 3043 Keep-Alive timeout=15, max=100 Connection Keep-Alive Content-Type application/xhtml+xml; charset=UTF-8 " </code></pre> <p>EDIT: OK I understand that in this case serving a document with many MIMEs <strong>and</strong> having different languages (that can come from so many sources - see above) is just plain bad design. If you want to do this just use "private" cache (no cache on proxies)... Am I correct?</p> <p>If each language have it's own URL (but each URL can be served with many MIME still) is my current implementation is OK for a "public" cache (cache on clients + proxies)?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload