当前位置: 首页>>代码示例>>PHP>>正文


PHP OC_Response::enableCaching方法代码示例

本文整理汇总了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;
 }
开发者ID:noci2012,项目名称:owncloud,代码行数:27,代码来源:minimizer.php

示例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);
 }
开发者ID:adolfo2103,项目名称:hcloudfilem,代码行数:11,代码来源:response.php

示例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);
     }
 }
开发者ID:CDN-Sparks,项目名称:owncloud,代码行数:23,代码来源:thumbnail.php

示例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));
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:19,代码来源:router.php

示例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;
     }
 }
开发者ID:jaeindia,项目名称:ownCloud-Enhancements,代码行数:25,代码来源:base.php


注:本文中的OC_Response::enableCaching方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。