Skip to content

[5.x] Improve turbo frame caching - #1329

Open
Jade-GG wants to merge 6 commits into
masterfrom
feature/turbo-frames
Open

[5.x] Improve turbo frame caching#1329
Jade-GG wants to merge 6 commits into
masterfrom
feature/turbo-frames

Conversation

@Jade-GG

@Jade-GG Jade-GG commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator

ref: RAP-1969

This PR adds some basic standardized functionality for turbo frames, which allows us to improve the caching, adding the cachekey into the url. This solves the issue of turbo frames staying in cache longer than necessary when you clear the cache, which then in turn also often ended up causing a cache loop.

For this purpose, I've added a directive that can be used to insert turbo frames. It should be used like this in templates:

@turboframe('turbo-frame')

This then places the intended view with the $complete variable set to false directly on the page, and creates a turbo frame that will overwrite this with the same view but with $complete set to true.

For example, say you have a view included somewhere that looks like this, with one very heavy query:

<div class="...">
    Lorem ipsum dolor sit amet...
    @foreach (config('rapidez.models.category')::all() as $category)
        <div>{{ $category->name }}</div>
    @endforeach
</div>

We could change the @include to a @turboframe, and then modify the view like so:

<div class="...">
    Lorem ipsum dolor sit amet...
    @if ($complete ?? false)
        @foreach (config('rapidez.models.category')::all() as $category)
            <div>{{ $category->name }}</div>
        @endforeach
    @else
        {{-- You can also add a loading state if necessary! --}}
        <div>Loading...</div>
    @endif
</div>

@Jade-GG
Jade-GG force-pushed the feature/turbo-frames branch from d4ff2e5 to 0a056e4 Compare August 24, 2026 07:02
@Jade-GG
Jade-GG marked this pull request as ready for review August 24, 2026 07:03
@Jade-GG

Jade-GG commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

Depends on rapidez/blade-directives#24

@Jade-GG Jade-GG changed the title Feature/turbo frames Improve turbo frame caching Aug 24, 2026
@Jade-GG Jade-GG changed the title Improve turbo frame caching [5.x] Improve turbo frame caching Aug 24, 2026
@Jade-GG

Jade-GG commented Aug 24, 2026

Copy link
Copy Markdown
Collaborator Author

Playwright errors caused by:

Access to fetch at 'http://localhost:1234/graphql' from origin 'http://localhost:8000' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values '*, *', but only one is allowed. Have the server send the header with a valid value.

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