Skip to content

Agentic UI: Always clear the preview cache when reloading - #4519

Merged
bcotrim merged 1 commit into
trunkfrom
stu-2217-fold-hard-refresh-into-reload
Aug 13, 2026
Merged

Agentic UI: Always clear the preview cache when reloading#4519
bcotrim merged 1 commit into
trunkfrom
stu-2217-fold-hard-refresh-into-reload

Conversation

@bcotrim

@bcotrim bcotrim commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Related issues

How AI was used in this PR

Claude Code made the change. It's a net deletion of the surface added in #4505.

Proposed Changes

#4505 added a separate "Hard refresh" option so users could shake loose a stale cached redirect. @sejas pointed out that the regular refresh button could just do this in all cases — then there's nothing extra to discover, and it also fixes the everyday annoyance of edited CSS/JS being served stale during development.

Reloading the preview now always drops the HTTP cache. Cost is limited to an explicit user action, and previews are local, so a refresh is cheap. Cookies live in a separate store, so preview logins are unaffected.

One thing had to come along: clearing the cache isn't enough on its own, because a cached redirect moves the webview's current entry onto the other site and reload() would reload that. Reload now re-navigates to the site's own URL when it detects it's sitting off-origin, and reloads normally otherwise.

The dedicated menu item is gone, ⌘⇧R stays as an alias for reload so the browser habit isn't a dead key, and the automatic recovery from #4505 is unchanged.

Trade-off: you can no longer reload the preview with a warm cache, so you can't observe how your site behaves for a returning visitor.

Testing Instructions

  1. With a site running, edit a file its theme loads directly (e.g. add body { background: red } to the active theme's style.css).
  2. Press ⟳ in the preview — the change shows without any manual cache clear. Confirm ⌘⇧R does the same.
  3. Redirect recovery still works. Create a second site, give the first a wp-content/mu-plugins/redirect.php that 301s its front end to the second's port:
    <?php
    add_action( 'template_redirect', function () {
        wp_redirect( 'http://localhost:<other-port>/', 301 );
        exit;
    } );
    Open its preview (shows the other site), delete the mu-plugin, confirm curl -sI returns 200 with no Location, then press ⟳ — it returns to the right site.
  4. Switching away and back should still self-heal without pressing anything.
  5. Confirm wp-admin still auto-logs in after a reload — the cache clear must not drop cookies.

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@wpmobilebot

Copy link
Copy Markdown
Collaborator

📊 Performance Test Results

Comparing 9abcb20 vs trunk

app-size

Metric trunk 9abcb20 Diff Change
App Size (Mac) 1406.62 MB 1406.62 MB 0.00 MB ⚪ 0.0%

site-editor

Metric trunk 9abcb20 Diff Change
load 1060 ms 1030 ms 30 ms ⚪ 0.0%

site-startup

Metric trunk 9abcb20 Diff Change
siteCreation 7528 ms 7516 ms 12 ms ⚪ 0.0%
siteStartup 2870 ms 2868 ms 2 ms ⚪ 0.0%

Results are median values from multiple test runs.

Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff)

@bcotrim
bcotrim requested a review from sejas August 12, 2026 17:04

@sejas sejas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as expected thanks! Now we'll use hard refresh always minimizing any other issue.

hard-refresh-fixes-301.mp4

@bcotrim
bcotrim merged commit 7cb0017 into trunk Aug 13, 2026
14 checks passed
@bcotrim
bcotrim deleted the stu-2217-fold-hard-refresh-into-reload branch August 13, 2026 09:10
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.

3 participants