Example #1
0
        break;
    case 'png'  : $mimetype = 'image/png';
        break;
    case 'jpg'  : $mimetype = 'image/jpeg';
        break;
    case 'jpeg' : $mimetype = 'image/jpeg';
        break;
    case 'ico'  : $mimetype = 'image/vnd.microsoft.icon';
        break;
    case 'svg'  : $mimetype = 'image/svg+xml';
        break;
    case 'js'   : $mimetype = 'application/javascript';
        break;
    case 'css'  : $mimetype = 'text/css';
        break;
    case 'php'  : jquery_file_not_found();
        break;
    default     : $mimetype = 'document/unknown';
}

if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    // We do not actually need to verify the etag value because these files
    // never change, devs need to change file names on update!
    header('HTTP/1.1 304 Not Modified');
    header('Expires: '. gmdate('D, d M Y H:i:s', time() + $lifetime) .' GMT');
    header('Cache-Control: public, max-age='.$lifetime);
    header('Content-Type: '.$mimetype);
    header('Etag: '.$etag);
    die;
}
Example #2
0
        $mimetype = 'image/jpeg';
        break;
    case 'ico':
        $mimetype = 'image/vnd.microsoft.icon';
        break;
    case 'svg':
        $mimetype = 'image/svg+xml';
        break;
    case 'js':
        $mimetype = 'application/javascript';
        break;
    case 'css':
        $mimetype = 'text/css';
        break;
    case 'php':
        jquery_file_not_found();
        break;
    default:
        $mimetype = 'document/unknown';
}
if (!empty($_SERVER['HTTP_IF_NONE_MATCH']) || !empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
    // We do not actually need to verify the etag value because these files
    // never change, devs need to change file names on update!
    header('HTTP/1.1 304 Not Modified');
    header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT');
    header('Cache-Control: public, max-age=' . $lifetime);
    header('Content-Type: ' . $mimetype);
    header('Etag: "' . $etag . '"');
    die;
}
require_once "{$CFG->dirroot}/lib/xsendfilelib.php";