src/Controller/Base.php
protected function serveFromCache($file, $hit = true, $setCacheHeaders = true)
    {
        /**
         * Cache object exists, set the appropriate headers and return the
         * contents of the file.
         **/

        $aStats = stat($this->cdnCacheDir . $file);

        //  Set cache headers
        if ($setCacheHeaders) {
            $this->setCacheHeaders($aStats['mtime'], $file, $hit);
        }

        //  Work out content type
        $oCdn  = Factory::service('Cdn', 'nails/module-cdn');
        $sMime = $oCdn->getMimeFromFile($this->cdnCacheDir . $file);

        header('Content-Type: ' . $sMime, true);
        header('Content-Length: ' . $aStats['size']);

        // --------------------------------------------------------------------------

        //  Send the contents of the file to the browser
        Factory::helper('file');
        readFileChunked($this->cdnCacheDir . $file);

        /**
         * Kill script, th, th, that's all folks.
         * Stop the output class from hijacking our headers and
         * setting an incorrect Content-Type
         **/

        exit(0);
    }
protected function serveFromCache($file, $hit = true, $setCacheHeaders = true)
    {
        /**
         * Cache object exists, set the appropriate headers and return the
         * contents of the file.
         **/

        $aStats = stat($this->cdnCacheDir . $file);

        //  Set cache headers
        if ($setCacheHeaders) {
            $this->setCacheHeaders($aStats['mtime'], $file, $hit);
        }

        //  Work out content type
        $oCdn  = Factory::service('Cdn', 'nails/module-cdn');
        $sMime = $oCdn->getMimeFromFile($this->cdnCacheDir . $file);

        header('Content-Type: ' . $sMime, true);
        header('Content-Length: ' . $aStats['size']);

        // --------------------------------------------------------------------------

        //  Send the contents of the file to the browser
        Factory::helper('file');
        readFileChunked($this->cdnCacheDir . $file);

        /**
         * Kill script, th, th, that's all folks.
         * Stop the output class from hijacking our headers and
         * setting an incorrect Content-Type
         **/

        exit(0);
    }
protected function serveFromCache ( $ file , $ hit = true , $ setCacheHeaders = true ) { /**
         * Cache object exists, set the appropriate headers and return the
         * contents of the file.
         **/ $ aStats = stat ( $ this -> cdnCacheDir . $ file ) ; //  Set cache headers if ( $ setCacheHeaders ) { $ this -> setCacheHeaders ( $ aStats [ 'mtime' ] , $ file , $ hit ) ; } //  Work out content type $ oCdn = Factory :: service ( 'Cdn' , 'nails/module-cdn' ) ; $ sMime = $ oCdn -> getMimeFromFile ( $ this -> cdnCacheDir . $ file ) ; header ( 'Content-Type: ' . $ sMime , true ) ; header ( 'Content-Length: ' . $ aStats [ 'size' ] ) ; // -------------------------------------------------------------------------- //  Send the contents of the file to the browser Factory :: helper ( 'file' ) ; readFileChunked ( $ this -> cdnCacheDir . $ file ) ; /**
         * Kill script, th, th, that's all folks.
         * Stop the output class from hijacking our headers and
         * setting an incorrect Content-Type
         **/ exit ( 0 ) ; }
Serve a file from the app's cache

@param  string  $file            The file to serve
@param  boolean $hit             Whether or not the request was a cache hit or not
@param  boolean $setCacheHeaders Whether tos et the cache headers or not

@return void
Serve a file from the app s cache