Caching dynamically generated PHP files can increase site speed by saving the result in a static file and serving it in subsequent requests. PHP pages are cached by the unique URI associated with each page. With caching enabled, dynamically generated PHP pages are cached at the edge and served as static files. Caching makes applications significantly faster by reducing the amount of time and resources it takes to render a page.
To instruct Amezmo to cache your dynamically generated PHP pages, ensure the following requirements for each page you want to cache.
: Cookies, as in the
Set-CookieHTTP response header must not be present in any cachable page.
- Cache-Control : This HTTP response header must *not* be present.
- Expires : This HTTP response header must *not* be present.
- 200 HTTP Response code Amezmo will consider only 200 level responses as candiates to be cached.
It's important that you don't cache sensitive pages such as Admin portals and other pages which must never be cached like password reset forms.
POST requests are never cached.
Important:. If you're using a PHP framework such as Laravel, or Yii, then cookies may be automatically added to your HTTP responses. You must disable this functionality before PHP caching will work. To disable cookies, see the documentation for your framework.
- When a page is cached, the cached version will serverd for up to 24 hours. See ways of purging the cache for more information.
- Caching has an aggregate size limit of 256MB.
GETrequests are canidates for caching.
- Marketing pages. Your marketing pages are dynamically generated with a template engine such as Blade, or Twig. These pages don't change often but each HTTP request must call into PHP-FPM and run the PHP engine to generate the page. Caching these pages would make your marketing site behave as if it was a static HTML site instead.
- WordPress. Your blog posts probably don't change often, so there's no reason to have PHP regenerate the page for each requests.