craft-blitz icon indicating copy to clipboard operation
craft-blitz copied to clipboard

Pages are not caching and not generating any logs

Open pbmills opened this issue 1 year ago • 10 comments

Bug Report

I've just installed the Blitz plugin and followed the basic setup steps from the documentation within the CMS settings. However, when I navigate to different pages, they aren't being cached. I'm using Blitz to improve my website's load speed, particularly because it contains a large number of images.

Diagnostics Report

Application Info

  • PHP version: 8.2.22
  • Craft edition & version: Pro 5.4.8
  • Database driver & version: MySQL 8.0.36

Installed Plugins

  • Blitz: 5.9.0
  • Button Box: 5.0.0
  • CKEditor: 4.3.0
  • Control Panel CSS: 3.0.0
  • CP Field Inspect: 2.0.2
  • Embedded Assets: 5.1.2
  • Feed Me: 6.5.0
  • Field Manager: 4.0.3
  • Formie: 3.0.9
  • Imager X: 5.0.2
  • Maps: 5.0.3
  • MJML: 5.0.1
  • SEOmatic: 5.1.4
  • Simple: 1.0.0
  • Table Maker: 5.0.3
  • UI Element fields: 3.0.0
  • Vite: 5.0.1

Loaded Modules

  • codeeditor: nystudio107\codeeditor\CodeEditor
  • sprig-core: putyourlightson\sprig\Sprig
  • verbb-base: verbb\base\Base

Blitz Plugin Settings

{
    "debug": false,
    "hintsEnabled": true,
    "cachingEnabled": true,
    "refreshCacheEnabled": true,
    "refreshMode": 1,
    "includedUriPatterns": {
        "1": {
            "enabled": "1",
            "uriPattern": ".*"
        },
        "2": {
            "enabled": "1",
            "uriPattern": ""
        }
    },
    "excludedUriPatterns": [],
    "cacheStorageType": "putyourlightson\\blitz\\drivers\\storage\\FileStorage",
    "cacheStorageSettings": {
        "folderPath": "@webroot\/cache\/blitz",
        "compressCachedValues": ""
    },
    "cacheStorageTypes": [],
    "cacheGeneratorType": "putyourlightson\\blitz\\drivers\\generators\\HttpGenerator",
    "cacheGeneratorSettings": {
        "concurrency": "3"
    },
    "cacheGeneratorTypes": [],
    "customSiteUris": [],
    "cachePurgerType": "putyourlightson\\blitz\\drivers\\purgers\\DummyPurger",
    "cachePurgerSettings": [],
    "cachePurgerTypes": [],
    "deployerType": "putyourlightson\\blitz\\drivers\\deployers\\DummyDeployer",
    "deployerSettings": [],
    "deployerTypes": [],
    "ssiEnabled": false,
    "ssiTagFormat": "<!--#include virtual=\"{uri}\" -->",
    "detectSsiEnabled": true,
    "esiEnabled": false,
    "onlyCacheLowercaseUris": false,
    "queryStringCaching": 0,
    "includedQueryStringParams": [
        {
            "enabled": "1",
            "queryStringParam": ".*"
        }
    ],
    "excludedQueryStringParams": [
        {
            "enabled": "1",
            "queryStringParam": "gclid"
        },
        {
            "enabled": "1",
            "queryStringParam": "fbclid"
        }
    ],
    "apiKey": "",
    "generatePagesWithQueryStringParams": true,
    "purgeAssetImagesWhenChanged": true,
    "refreshCacheAutomaticallyForGlobals": true,
    "refreshCacheWhenElementMovedInStructure": true,
    "refreshCacheWhenElementSavedUnchanged": false,
    "refreshCacheWhenElementSavedNotLive": false,
    "cacheNonHtmlResponses": false,
    "trackElements": true,
    "trackElementQueries": true,
    "excludedTrackedElementQueryParams": [],
    "cacheDuration": null,
    "nonCacheableElementTypes": [],
    "sourceIdAttributes": [],
    "liveStatuses": [],
    "integrations": [
        "putyourlightson\\blitz\\drivers\\integrations\\CommerceIntegration",
        "putyourlightson\\blitz\\drivers\\integrations\\SeomaticIntegration"
    ],
    "defaultCacheControlHeader": "no-store",
    "cacheControlHeader": "public, s-maxage=31536000, max-age=0",
    "cacheControlHeaderExpired": "public, s-maxage=5, max-age=0",
    "sendPoweredByHeader": true,
    "outputComments": true,
    "refreshCacheJobPriority": 10,
    "driverJobBatchSize": 100,
    "driverJobPriority": 100,
    "queueJobTtr": 300,
    "maxRetryAttempts": 10,
    "maxUriLength": 255,
    "mutexTimeout": 1,
    "commands": [],
    "injectScriptEvent": "DOMContentLoaded",
    "injectScriptPosition": 3
}

Recommendations

  • ❌ One or more globals exist and refreshCacheAutomaticallyForGlobals is enabled.
  • ❌ Queue jobs are configured to run automatically via web requests.
  • ❌ The blitz/cache/refresh-expired console command has not been executed within the past 24 hours.
  • ✅ Blitz is configured not to refresh cached pages when an element is saved but unchanged.
  • ✅ Blitz is configured not to refresh cached pages when an element is saved but not live.
  • ✅ Image transforms are configured to be generated before page load.
  • ✅ The @web alias is not used in the base URL of any sites.
  • ✅ The Blitz Hints utility is not reporting any eager-loading opportunities.
  • ✅ The Async Queue plugin is not installed or enabled.

Site Tracking

  • Tracked Pages: 0
  • Tracked Includes: 0
  • Tracked Query String Params: 0
  • Tracked Elements: 0
  • Tracked Element Queries: 0
  • Tracked Tags: 0

pbmills avatar Oct 21 '24 07:10 pbmills

Enabling debug mode should log the reason for pages not being cached to the storage/logs/blitz-* logs. If nothing is showing in the logs, then I’m not sure what to suggest. Are you running this in DDEV or another local development environment?

bencroker avatar Oct 21 '24 15:10 bencroker

@bencroker I am running this in DDEV. I have enabled debug mode after reinstalling the whole project.

The logs are showing me this when I ddev php craft blitz/cache/generate

I have already ->generateTransformsBeforePageLoad(true) in my general.php config file.

Screenshot 2024-10-22 at 11 11 55 AM

I'm not sure what else should I be trying here.

pbmills avatar Oct 21 '24 22:10 pbmills

Great! Can you now view the HTML source code of one of those pages and search for assets/generate-transform? That is what Blitz looks for to determine whether to skip caching the page. In case you find it in a meta tag, it might be produced by a plugin such as SEOmatic.

bencroker avatar Oct 22 '24 06:10 bencroker

@bencroker as soon as I disabled my SEOmatic plugin the Blitz started working locally. This is interesting. I did saw couple of issue related to similar issue but there isn't a place where I can find a solution of working with SEOmatic and Blitz together. Do you have any idea ?

pbmills avatar Oct 22 '24 07:10 pbmills

Most of those I’ve seen have to do with incorrectly configured asset paths, in the end.

bencroker avatar Oct 22 '24 07:10 bencroker

Is that incorrect setup of the asset paths for the Imager-x am I right?

pbmills avatar Oct 22 '24 07:10 pbmills

Yes, but I thought you said SEOmatic was the culprit?

bencroker avatar Oct 22 '24 07:10 bencroker

SEOmatic is causing the issue, and there are reports that using it with ImagerX can lead to conflicts, particularly around image transforms. It's a known compatibility problem that might require reviewing the setup or adjusting how transforms are handled. I'm still reviewing in on how to fix it :(

pbmills avatar Oct 22 '24 07:10 pbmills

Ok, let me know how it goes.

bencroker avatar Oct 22 '24 07:10 bencroker

For what it's worth, SEOmatic doesn't do anything special. It just does regular old Craft image transforms.

Usually when people run into this issue, it ends up being that image transforms are failing for one reason or another, which leaves the image transform URL in the HTML.

khalwat avatar Oct 22 '24 16:10 khalwat

@pbmills can you give us any insights into your resolution here?

khalwat avatar Nov 01 '24 19:11 khalwat

I’ve turned off image transforms for General, X (Twitter), and Facebook in SEOMatic’s Content SEO settings for Blitz to work @khalwat.

When I enable image transforms, the HTML output includes URLs like assets/generate-transform on page views.

Screenshot 2024-11-05 at 11 55 51 PM Screenshot 2024-11-05 at 11 55 00 PM

When I turn off image transforms, this is the output I receive.

Screenshot 2024-11-05 at 11 56 29 PM Screenshot 2024-11-05 at 11 56 18 PM

pbmills avatar Nov 05 '24 11:11 pbmills