本文整理汇总了PHP中OC_Response::enableCaching方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_Response::enableCaching方法的具体用法?PHP OC_Response::enableCaching怎么用?PHP OC_Response::enableCaching使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_Response
的用法示例。
在下文中一共展示了OC_Response::enableCaching方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: output
public function output($files, $cache_key)
{
header('Content-Type: ' . $this->contentType);
OC_Response::enableCaching();
$etag = $this->generateETag($files);
$cache_key .= '-' . $etag;
$gzout = false;
$cache = OC_Cache::getGlobalCache();
if (!OC_Request::isNoCache() && (!defined('DEBUG') || !DEBUG)) {
OC_Response::setETagHeader($etag);
$gzout = $cache->get($cache_key . '.gz');
}
if (!$gzout) {
$out = $this->minimizeFiles($files);
$gzout = gzencode($out);
$cache->set($cache_key . '.gz', $gzout);
OC_Response::setETagHeader($etag);
}
if ($encoding = OC_Request::acceptGZip()) {
header('Content-Encoding: ' . $encoding);
$out = $gzout;
} else {
$out = gzdecode($gzout);
}
header('Content-Length: ' . strlen($out));
echo $out;
}
示例2: enableCaching
/**
* Enable response caching by sending correct HTTP headers
* @param int $cache_time time to cache the response
* >0 cache time in seconds
* 0 and <0 enable default browser caching
* null cache indefinitly
*/
public static function enableCaching($cache_time = null)
{
\OC_Response::enableCaching($cache_time);
}
示例3: show
public function show()
{
if ($this->useOriginal) {
$fp = @$this->view->fopen($this->path, 'rb');
$mtime = $this->view->filemtime($this->path);
$size = $this->view->filesize($this->path);
$mime = $this->view->getMimetype($this->path);
} else {
$fp = @fopen($this->path, 'rb');
$mtime = filemtime($this->path);
$size = filesize($this->path);
$mime = \OC_Helper::getMimetype($this->path);
}
if ($fp) {
\OC_Response::enableCaching();
\OC_Response::setLastModifiedHeader($mtime);
header('Content-Length: ' . $size);
header('Content-Type: ' . $mime);
fpassthru($fp);
} else {
\OC_Response::setStatus(\OC_Response::STATUS_NOT_FOUND);
}
}
示例4: JSRoutes
/**
* Generate JSON response for routing in javascript
*/
public static function JSRoutes()
{
$router = OC::getRouter();
$etag = $router->getCacheKey();
OC_Response::enableCaching();
OC_Response::setETagHeader($etag);
$root = $router->getCollection('root');
$routes = array();
foreach ($root->all() as $name => $route) {
$compiled_route = $route->compile();
$defaults = $route->getDefaults();
unset($defaults['action']);
$routes[$name] = array('tokens' => $compiled_route->getTokens(), 'defaults' => $defaults);
}
OCP\JSON::success(array('data' => $routes));
}
示例5: loadfile
public static function loadfile()
{
if (file_exists(OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE)) {
if (substr(OC::$REQUESTEDFILE, -3) == 'css') {
$appswebroot = (string) OC::$APPSWEBROOT;
$webroot = (string) OC::$WEBROOT;
$filepath = OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE;
header('Content-Type: text/css');
OC_Response::enableCaching();
OC_Response::setLastModifiedHeader(filemtime($filepath));
$cssfile = file_get_contents($filepath);
$cssfile = str_replace('%appswebroot%', $appswebroot, $cssfile);
$cssfile = str_replace('%webroot%', $webroot, $cssfile);
OC_Response::setETagHeader(md5($cssfile));
header('Content-Length: ' . strlen($cssfile));
echo $cssfile;
exit;
} elseif (substr(OC::$REQUESTEDFILE, -3) == 'php') {
require_once OC::$APPSROOT . '/apps/' . OC::$REQUESTEDAPP . '/' . OC::$REQUESTEDFILE;
}
} else {
header('HTTP/1.0 404 Not Found');
exit;
}
}