Skip to content

Images do not update when changed on disk #110

Description

@schuyler

Problem

When an external image referenced in a Markdown document is modified on disk, the preview does not automatically show the updated image. The preview continues to show the cached version until the document is closed and reopened.

Root Cause

This issue was reintroduced as a known trade-off when fixing issue #9 (preview pane flickering).

Historically, PR #747 in the original MacDown repository added code to disable WebView's cache using private API ([WebCache setDisabled:YES]). This solved the image caching problem but caused WebKit to reload ALL resources (stylesheets, JavaScript, HTML) on every keystroke, resulting in severe flickering (issue #9).

To fix the flickering, we removed the WebCache disabling code in PR #109, which reintroduced this image caching issue.

Impact

Severity: Low to Medium

  • Only affects users who:
    1. Reference external images in their Markdown
    2. Modify those images on disk while editing
    3. Need to see the updated image without reloading the document

Workaround: Close and reopen the document to see updated images.

Related Issues

Trade-off Analysis

What we fixed: Preview pane flickering on every keystroke (high-impact, affects core writing experience)

What we regressed: Images not updating when changed on disk (lower-impact, affects specific workflows)

This trade-off prioritizes the everyday user experience over an edge case.

Potential Solutions

Option 1: Migrate to WKWebView (RECOMMENDED)

The long-term solution is to migrate from the deprecated WebView to modern WKWebView. This would provide:

  • Proper cache control APIs (no private API needed)
  • Better rendering performance
  • Potential elimination of flickering issues
  • Support for modern web standards

See separate issue for WKWebView migration planning.

Option 2: Selective Cache Invalidation

Instead of disabling all caching, selectively invalidate image caches when:

  • The document regains focus
  • A manual refresh is triggered
  • File system events detect image changes

This would require significant implementation effort and may not be worth it before WKWebView migration.

Option 3: Manual Refresh Command

Provide a menu item or keyboard shortcut to force-reload the preview, clearing all caches. This gives users control without impacting normal typing performance.

Priority

Medium - Not urgent since there's a workaround, but should be addressed as part of WKWebView migration or as a quality-of-life improvement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions