thoughtco / statamic-cache-tracker

12 stars 2 forks source link

Known limitations? #22

Open SteJW opened 1 day ago

SteJW commented 1 day ago

Hi, I'm testing with using the addon in combination with the full cache. I can see it works great for the most part. I have about 2200 HTML files. However, I'm using a global title for the on every page. When I change this title, it clears about 95% of the pages. Any idea why it's skipping the rest of them? Any idea where to look for?

ryanmitchell commented 1 day ago

Is there any consistency in the ones that are being skipped (eg they have query params, or they are routes you've defined?).

You could get the manifest for those urls and see if your global is tagged in them - \Thoughtco\StatamicCacheTracker\Facades\Tracker:: get($url)

SteJW commented 1 day ago

No, I can't find any consistency unfortunately. I have 2 simple pages:

/privacy-statement /fietsen

They are both cached, both have a HTML file. /privacy-statement return NULL.

When I look up /fietsen, I get a ton tags:

array(2) {
  ["url"]=>
  string(44) "https://url.loc/fietsen"
  ["tags"]=>
  array(75) {
    [0]=>
    string(27) "partial:_components/widgets"
    [1]=>
    string(74) "partial:_components/page_builder/widget_banner_slider/widget_banner_slider"
    [2]=>
    string(44) "banners:63b2f0b4-1a64-46e1-8496-df063a372d5a"
    [3]=>
    string(60) "asset:assets::banners/banner_fietsen/img_20230622_100733.png"
    [4]=>
    string(68) "partial:_components/page_builder/widget_links_grid/widget_links_grid"
    [5]=>
    string(85) "partial:_components/page_builder/widget_links_grid/partials/layout_three/layout_three"
    [6]=>
    string(43) "asset:assets::widgets/fietsen/jankooij1.png"
    [7]=>
    string(43) "asset:assets::widgets/fietsen/jankooij5.png"
    [8]=>
    string(43) "asset:assets::widgets/fietsen/jankooij6.png"
    [9]=>
    string(66) "partial:_components/page_builder/widget_cta_small/widget_cta_small"
    [10]=>
    string(86) "partial:_components/page_builder/widget_collapsible_content/widget_collapsible_content"
    [11]=>
    string(90) "partial:_components/page_builder/widget_text_block_with_media/widget_text_block_with_media"
    [12]=>
    string(78) "partial:_components/page_builder/widget_text_block_with_media/partials/default"
    [13]=>
    string(27) "asset:assets::JanKooij1.png"
    [14]=>
    string(58) "partial:_components/page_builder/widget_album/widget_album"
    [15]=>
    string(43) "albums:25f9a366-e32a-4c25-a12a-5cc9e2e7a83a"
    [16]=>
    string(51) "asset:assets::albums/fietsen/Fietsen/Fietsen-13.jpg"
    [17]=>
    string(52) "asset:assets::albums/fietsen/Jan_Kooij/JanKooij6.png"
    [18]=>
    string(52) "asset:assets::albums/fietsen/Jan_Kooij/JanKooij4.png"
    [19]=>
    string(52) "asset:assets::albums/fietsen/Jan_Kooij/JanKooij7.png"
    [20]=>
    string(52) "asset:assets::albums/fietsen/Jan_Kooij/JanKooij5.png"
    [21]=>
    string(52) "asset:assets::albums/fietsen/Jan_Kooij/JanKooij3.png"
    [22]=>
    string(31) "partial:_molecules/seo/seo_head"
    [23]=>
    string(10) "global:seo"
    [24]=>
    string(15) "global:trackers"
    [25]=>
    string(34) "partial:_molecules/seo/social_head"
    [26]=>
    string(30) "partial:_molecules/seo/favicon"
    [27]=>
    string(43) "partial:_molecules/seo/structured_data_head"
    [28]=>
    string(19) "global:social_media"
    [29]=>
    string(14) "global:reviews"
    [30]=>
    string(29) "asset:assets::vg-og-image.png"
    [31]=>
    string(31) "partial:_molecules/seo/seo_body"
    [32]=>
    string(29) "partial:_layout/header/header"
    [33]=>
    string(13) "global:header"
    [34]=>
    string(42) "pages:e2a14c46-5a0a-49c3-bd64-8374695e1021"
    [35]=>
    string(19) "nav:main_navigation"
    [36]=>
    string(42) "pages:a968156b-2bd2-4d94-84ac-b6d12406787d"
    [37]=>
    string(73) "asset:assets::widgets/zakelijk/leasevormen/verkoper-met-klant-in-auto.jpg"
    [38]=>
    string(20) "nav:extra_navigation"
    [39]=>
    string(43) "brands:538ce2e8-ab5e-433f-9b02-60c8ef359246"
    [40]=>
    string(43) "brands:d7d9a9c8-815d-4d05-b2af-2fe9532c98d4"
    [41]=>
    string(43) "brands:cf313a74-4220-4ed4-a07f-7d3e58593c8e"
    [42]=>
    string(43) "brands:29a5fbf5-4d02-4579-9df2-3c06e91e0678"
    [43]=>
    string(43) "brands:1658ef07-f197-446e-a676-40a898f20f58"
    [44]=>
    string(43) "brands:eda1d75f-e8a9-4f03-8ef7-6c4944c74cdc"
    [45]=>
    string(46) "asset:assets::widgets/monteur-5-1724663135.jpg"
    [46]=>
    string(60) "asset:assets::banners/Banners_schade/Autoschadebedrijf_1.JPG"
    [47]=>
    string(20) "nav:handy_navigation"
    [48]=>
    string(37) "asset:assets::widgets/slim-leasen.jpg"
    [49]=>
    string(70) "asset:assets::widgets/zakelijke-actie-polo-fabia-ibiza-actiebanner.jpg"
    [50]=>
    string(55) "asset:assets::widgets/verkoop-aflevering-1724664526.jpg"
    [51]=>
    string(52) "asset:assets::widgets/zakelijk/verkoop-collega's.jpg"
    [52]=>
    string(105) "asset:assets::widgets/zakelijk/web-ready-jpg-polo_r_line_world_premiere_still_appconnect_po4865_clean.jpg"
    [53]=>
    string(18) "nav:top_navigation"
    [54]=>
    string(42) "pages:ce378910-c285-4df6-98ef-786515c84afd"
    [55]=>
    string(42) "pages:bd2c7dcd-396f-4505-9a59-19d1d43724db"
    [56]=>
    string(29) "partial:_layout/footer/footer"
    [57]=>
    string(19) "nav:footer_column_1"
    [58]=>
    string(42) "pages:0a419e5d-09bd-4246-a0d8-cb5f3bee054e"
    [59]=>
    string(42) "pages:fc0beb85-38dd-43cf-b369-065a2af511b8"
    [60]=>
    string(42) "pages:22750332-0d72-4a16-a0ad-1ac6b5d06a78"
    [61]=>
    string(13) "global:footer"
    [62]=>
    string(19) "nav:footer_column_2"
    [63]=>
    string(42) "pages:260651f4-e1db-4ac2-8111-1539527ec3be"
    [64]=>
    string(42) "pages:f9d5860a-57bf-4bae-8d92-a527a7cda0d1"
    [65]=>
    string(42) "pages:d0a27426-3017-4c7c-8e47-087251b086d0"
    [66]=>
    string(19) "nav:footer_column_3"
    [67]=>
    string(42) "pages:88f50caf-a51f-4aca-ade7-41010cb281d6"
    [68]=>
    string(42) "pages:a546334b-dc6c-42a5-9363-602322a9cb14"
    [69]=>
    string(17) "nav:footer_bottom"
    [70]=>
    string(42) "pages:f2ae91f0-43fa-4b02-a0fc-756269b9b41a"
    [71]=>
    string(42) "pages:87624ac4-9738-4b9b-afc1-1d6e421dfac1"
    [72]=>
    string(42) "pages:30392784-ac52-4f09-9c76-2f316047ed2a"
    [73]=>
    string(42) "pages:4a4fb4fb-dcc5-4bc3-95d5-e445b42b03c2"
    [74]=>
    string(38) "partial:_molecules/seo/seo_body_footer"
  }
}
SteJW commented 1 day ago

So, when I update the privacy statement in Statamic, it clears the cache for both the privacy statement page and the "fietsen" page. I can see this in Horizon: 2024-10-31 14:38:41 Statamic\StaticCaching\Invalidate .............. RUNNING 2024-10-31 14:38:41 Statamic\StaticCaching\Invalidate ......... 31.49ms DONE 2024-10-31 14:38:41 Thoughtco\StatamicCacheTracker\Jobs\InvalidateTags RUNNING 2024-10-31 14:38:41 Thoughtco\StatamicCacheTracker\Jobs\InvalidateTags 19.21ms DONE 2024-10-31 14:38:41 Statamic\Search\UpdateItemIndexes .............. RUNNING 2024-10-31 14:38:42 Statamic\Search\UpdateItemIndexes ........ 824.16ms DONE 2024-10-31 14:38:42 Statamic\StaticCaching\Invalidate .............. RUNNING 2024-10-31 14:38:42 Statamic\StaticCaching\Invalidate ......... 98.87ms DONE 2024-10-31 14:38:42 Thoughtco\StatamicCacheTracker\Jobs\InvalidateTags RUNNING 2024-10-31 14:38:45 Thoughtco\StatamicCacheTracker\Jobs\InvalidateTags 2s DONE

Then, I go to /fietsen and /privacy-statement.

Ater that, I run the cache lookup code you send and then I find results for both.

Is there a way that the static:warm create the HTML file for privacy-statement, but it doesn't add the tags in the cache?

ryanmitchell commented 1 day ago

Had you cleared your static cache after you installed this add on?

SteJW commented 1 day ago

Yes, I did. I cleared everything and have re-run the cache.

ryanmitchell commented 1 day ago

Odd then. When you warm the cache are you allowing concurrent requests?

SteJW commented 1 day ago

I don't know. How can I check? I'm testing locally.

Another update; I have update the entry privacy statement from the cp to see what it does. Now, when I redo the caching, it does get it's tags connected to it. Seems like doing a save one time helped. I still have this problem with other URL's though. Does it perhaps have something to do with a modified timestamp or something? Where or when is the cache->add() being triggered? Maybe I can find something there?

ryanmitchell commented 1 day ago

I don't know. How can I check? I'm testing locally.

When you are running the warm command are you passing anything to it to have concurrency or are you running it on a queue?

Another update; I have update the entry privacy statement from the cp to see what it does. Now, when I redo the caching, it does get it's tags connected to it. Seems like doing a save one time helped. I still have this problem with other URL's though. Does it perhaps have something to do with a modified timestamp or something? Where or when is the cache->add() being triggered? Maybe I can find something there?

I think the issue is coming from you warming it - oddly I'm not able to recreate that issue - when I warm I do get all the tags added. The tagging is done through middleware: https://github.com/thoughtco/statamic-cache-tracker/blob/cdcb43d47787abd06d1339224f8036c97387ccba/src/Http/Middleware/CacheTracker.php#L79-L81

SteJW commented 1 day ago

No, I simply use the terminal: php artisan static:warm

Thanks for pointing out, I'll see if I can find something. Like I said before, the weird thing is that after saving the privacy statement once, It is getting picked up. There are pages that have been added from a migration script. Maybe there could be missing something there? That has been 2 months ago though and the pages are working when navigating to it, they might have never been saved in the CP itself. Just a thought.

ryanmitchell commented 21 hours ago

Possibly - that’s hard to know but it seems unlikely. As long as the url can be hit it should be tracked.