stale-while-revalidate and stale-if-error are not working together in Squid 2.7 as seen here:
http://www.igvita.com/2009/08/05/masking-latency-failures-with-squid/
The squid is running with the next conf:
http_port 80 accel defaultsite=mydomain.com
cache_peer 127.0.0.1 parent 8000 0 no-query originserver name=main
httpd_suppress_version_string on
header_access Cache-Control deny all
cache_effective_user squid
negative_ttl 5 seconds
And in the backend php+apache server at port 8000 I return this:
<?php
// trigger_error("Throw error 500", E_USER_ERROR");
header('Cache-Control: max-age=10, stale-while-revalidate=20 stale-if-error=20');
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
sleep(2);
die("OK");
When I uncomment the trigger_error if I send the stale-while-revalidate then client gets the error, if I send this next one the stale-if-error works as expected:
<?php
trigger_error("Throw error 500", E_USER_ERROR");
header('Cache-Control: max-age=10, stale-if-error=20');
// Next one don't works
// header('Cache-Control: max-age=10, stale-while-revalidate=20 stale-if-error=20');
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
sleep(2);
die("OK");