OctoberCMS Development Tips

 File : 

/vendor/symfony/http-foundation/ResponseHeaderBag.php 

Default :   return ‘no-cache, private’;

Modified to cache : return ‘public, max-age=14400’;

<pre class=”lang:default decode:true ” title=”OctoberCMS cache headers”> /**
* Returns the calculated value of the cache-control header.
*
* This considers several other headers and calculates or modifies the
* cache-control header to a sensible, conservative value.
*
* @return string
*/
protected function computeCacheControlValue()
{
if (!$this-&gt;cacheControl) {
if ($this-&gt;has(‘Last-Modified’) || $this-&gt;has(‘Expires’)) {
return ‘private, must-revalidate’; // allows for heuristic expiration (RFC 7234 Section 4.2.2) in the case of “Last-Modified”
}

// conservative by default
// return ‘no-cache, private’;
return ‘public, max-age=14400’;

}

$header = $this-&gt;getCacheControlHeader();
if (isset($this-&gt;cacheControl[‘public’]) || isset($this-&gt;cacheControl[‘private’])) {
return $header;
}

// public if s-maxage is defined, private otherwise
if (!isset($this-&gt;cacheControl[‘s-maxage’])) {
return $header.’, private’;
}

return $header;
}
</pre>
<p> </p>

 

 /**

     * Returns the calculated value of the cache-control header.

     *

     * This considers several other headers and calculates or modifies the

     * cache-control header to a sensible, conservative value.

     *

     * @return string

     */

    protected function computeCacheControlValue()

    {

        if (!$this->cacheControl) {

            if ($this->has(‘Last-Modified’) || $this->has(‘Expires’)) {

                return ‘private, must-revalidate’; // allows for heuristic expiration (RFC 7234 Section 4.2.2) in the case of “Last-Modified”

            }

            // conservative by default

           //  return ‘no-cache, private’;

            return ‘public, max-age=14400’;

        }

        $header = $this->getCacheControlHeader();

        if (isset($this->cacheControl[‘public’]) || isset($this->cacheControl[‘private’])) {

            return $header;

        }

        // public if s-maxage is defined, private otherwise

        if (!isset($this->cacheControl[‘s-maxage’])) {

            return $header.‘, private’;

        }

        return $header;

    }

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *