Extension caching
Some PHP extensions take a long time to compile and install. You can cache them using theshivammathur/cache-extensions action together with actions/cache.
When the cache is warm, extensions are enabled directly from the cache instead of being compiled again, which significantly reduces setup time.
The
shivammathur/cache-extensions action must run before setup-php so that the cache is restored before PHP setup begins. Refer to the cache-extensions documentation for full configuration options.Composer dependency caching
Composer maintains an internal download cache separate from thevendor directory. Caching this directory means packages are loaded from disk instead of being downloaded from Packagist on every run.
Basic setup with composer.lock
When you commitcomposer.lock, use its hash as the cache key. This ensures the cache is invalidated whenever your locked dependencies change.
When there is no composer.lock
If you do not commitcomposer.lock (common for libraries), use the hash of composer.json instead: