Download the PHP package fahlgrendigital/packages-statamic-cache-server without Composer

On this page you can find all versions of the php package fahlgrendigital/packages-statamic-cache-server. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package packages-statamic-cache-server

Statamic Cache Server

This package allows for configuration of a Statamic application to act as a caching server for page content.

Installation

Servers

This package expects there to be a minimum of two servers:

Both servers should have access to the same source of truth for content, images and cache stores. The details of what this means will be outlined later in this documentation.

Dev Ops

The above servers also need to sit behind an Application Load Balancer which functions different then a Network Load Balancer. AWS has the ability to easily spin up ALBs for your EC2 instances.

Usage

This package expects two types of utilization depending on the static caching strategy configured in the Statamic static_caching configuration:

Depending on the strategy your application is using, the caching server will function a bit differently. Those differences will be outlined in the following sections. Before going into the strategy-specific details, we'll cover how the cache server package works in general.

Overview

This overview will cover the following high-level functions:

Kick Off

This package has a command which acts as the ignition for the content caching process. That command mimics most of the built-in Statamic cache-warming command php please static:warm --user={username} --password={password} --queue. The signature looks like the following:

This command accepts the same arguments as the core Statamic command.

It is recommended to run this request from the application server rather than the cache server to save server resources for solely building the cache.

Note: This command does not clear the static cache beforehand. It is up to the caller to clear that cache, and it is highly recommended to do this otherwise the static cache will be built off of already-cached pages.

This custom command improves on the base static:warm command by batching the page requests when the --queue flag is used. It also improves on the --queue option by making sure to pass in the user/password params into the Guzzle request. The native Statamic command does not do this.

When the custom command is run, it kicks off a job which essentially just visits the configured page on the site, thereby triggering a cache of that page. This is where the magic of the cache server kicks in.

The batch containing all of the page requests has the following name: Statamic Custom FM Static Cache Warm

Page Requests

Page requests for the following content types are done by default in this command:

Note: The runway routes can be configured at cache-server.include.runway by supplying an array of Runway resource Models. It would look something like this:

Cache Building

In order for page requests to be routed to the cache server instead of your application server, your ALB must be configured to route cache requests properly. This package allows for a customizable header to be sent with all your cache requests which you can use in your ALB to properly route requests.

You may also configure the expected header values for filtering and security in your ALB.

The default values for build and static-clear are build and static-clear, respectively.

Cache Response

When the cache server detects a request for a page, it responds to the page like any other page, but at the end of the request this package has a terminable middleware which handles additional caching logic, particularly for the full caching strategy.

Half

Statamic includes documentation on how this strategy works. See their documentation for more details.

Full

Statamic includes documentation on how this strategy works. See their documentation for more details.

Cache Transfer

This section only applies when using the full strategy as it generates flat html files which your web server will serve up.

Once a page has been visited and a cache entry & flat file have been confirmed for that request, this package fires off two jobs in a chain which do the following in order:

Architecture

Getting the most out of this package will require some testing to see what server architecture works best for your situation. Whatever architecture is chosen, this package has some limitations which need to be taken into consideration:

Limitations

Recommendations

Cache

Statamic allows for the configuration of targeted redis database connections for storing things like: application cache, horizon data, pulse data, and glide data. Segmenting your data will make it easier to manage.

Recommendation: Redis

Images

When the caching server is building the cache, it will trigger glide image transformations and those glide images (and cached paths) need to be accessible to the application and cache servers. That's why it is necessary to have a central store for these images.

Recommendation: S3

DB Setup

If your Statamic application is leveraging a DB to store content, that DB will need to be accessible by the application and cache servers.

Cache Queue

The cache server leverages the database queue connection type to manage the jobs responsible for uploading and triggering static cache file downloads after a successful page cache.

To avoid conflicting database connections between the cache and application servers, it is highly recommend to set up a specific database connection for the cache server queue. Can be done by specifying a missing configuration within the queue configuration.

Add the following line to the database queue connection:

The QUEUE_DB_CONNECTION value will need to point to a specific database connection on the cache server only. For example if it is called queue-mysql, then in your database config the following section will need to be added:

Failed Jobs Table

Similar to the specific queue db connection settings, a connection for the failed jobs table will need to be established so the correct application reruns those failed jobs. Within the queue config modify the following lines to point to the connection you configured in the above section:

Migrations Note:

If your cache servers need to share a DB connection with the main application server for content, the migrations table will be shared as well. This means that the necessary jobs table required when using the database connection can get a bit squirrely. This table only needs to exist on the cache server. Depending on when and how your php artisan migrate is run that jobs table may end up on the wrong server and in the wrong database.

Currently, we don't have an elegant solution for this other than export the jobs schema and importing it into the correct queue database. After fixing the location of this table, the cache queue should run as expected. SORRY!


All versions of packages-statamic-cache-server with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
illuminate/support Version ^10.0
statamic/cms Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package fahlgrendigital/packages-statamic-cache-server contains the following files

Loading the files please wait ....