Skip to content

Recompile cache when timestamps are equal - #206

Merged
ganyicz merged 1 commit into
mainfrom
filip/fix-stale-compiled-cache
Aug 18, 2026
Merged

Recompile cache when timestamps are equal#206
ganyicz merged 1 commit into
mainfrom
filip/fix-stale-compiled-cache

Conversation

@ganyicz

@ganyicz ganyicz commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

The scenario

When a component source changes within the same second its compiled cache was written, Blaze can render stale output.

The problem

PHP file modification timestamps have one-second resolution, but the cache checks only consider a source stale when its modification time is greater than the compiled file:

filemtime($path) > filemtime($compiled)

The sequence is:

  1. Blaze compiles a component and writes its cache.
  2. The component source changes within the same second.
  3. The source and compiled file have equal modification times.
  4. The comparison returns false and Blaze reuses the stale cache.

This affects both isolated rendering during folding and runtime component compilation.

The solution

Treat equal timestamps as stale, matching Laravels cache expiration behavior:

- filemtime($path) > filemtime($compiled)
+ filemtime($path) >= filemtime($compiled)

Added regression tests for both cache paths.

Follow-up to #202

@github-actions

Copy link
Copy Markdown
Contributor

Benchmark Result: Default

Attempt Blade Blaze Change
#1 242.08ms 13.89ms 94.3%
#2 247.98ms 13.98ms 94.4%
#3 242.45ms 14.02ms 94.2%
#4 246.58ms 13.81ms 94.4%
#5 246.75ms 14.34ms 94.2%
#6 244.38ms 14.01ms 94.3%
#7 239.89ms 14.06ms 94.1%
#8 241.55ms 13.98ms 94.2%
#9 249.87ms 14.21ms 94.3%
#10 245.73ms 14.16ms 94.2%
Snapshot 241.64ms 14.11ms 94.2%
Result 245.06ms (~) 14.02ms (~) 94.3% (~)

Median of 10 attempts, 5000 iterations x 10 rounds, 33.32s total

To run a specific benchmark, comment /benchmark <name>
attributes, aware, class, default, forwarding, merge, named-slots, no-attributes, slot, compilation

@ganyicz
ganyicz merged commit 8f5a2b8 into main Aug 18, 2026
4 checks passed
@calebporzio
calebporzio deleted the filip/fix-stale-compiled-cache branch August 19, 2026 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant