Skip to content

CSS cache invalidation fails for remote/production sites after push #43

@tomatitito

Description

@tomatitito

Problem

After elementor-cli push to a production site, the page still serves stale CSS/content despite the CLI reporting "✔ Invalidated CSS cache". Manual intervention via SSH is required to actually flush the cache.

Root Cause

Two issues in the current invalidation logic:

1. invalidateCss() sets meta to empty string instead of deleting it

In src/services/wordpress-client.ts (L164-176), the method sets _elementor_css and _elementor_element_cache to "" (empty string) via REST API PUT. Elementor does not treat an empty string the same as a deleted/absent meta field — it needs the meta to be fully removed to trigger CSS regeneration.

What works: wp post meta delete <page-id> _elementor_css
What does not work: Setting _elementor_css to "" via REST API

The fix should use null instead of "" to delete the meta via REST API:

meta: {
  _elementor_css: null,
  _elementor_element_cache: null,
}

2. No wp elementor flush-css / wp cache flush for remote (SSH) sites

In src/commands/push.ts (L360-369), the container-based wp elementor flush-css only runs for sites with a container config (local Docker/Podman). Remote/production sites only get the (broken) REST API invalidation.

The CLI already supports SSH for db dump (--ssh and --ssh-path flags). The same SSH config should be usable for running wp elementor flush-css and wp cache flush on remote sites after push.

Steps to Reproduce

  1. Configure a production site without container config in .elementor-cli.yaml
  2. elementor-cli pull <page-id> --site production
  3. Make changes to the local page data
  4. elementor-cli push <page-id> --site production
  5. Observe: CLI reports success + "✔ Invalidated CSS cache"
  6. Load the page in browser (even with hard refresh) — old content/CSS is still served

Workaround

Manually run via SSH after pushing:

ssh user@host "wp --path=/path/to/wp post meta delete <page-id> _elementor_css"
ssh user@host "wp --path=/path/to/wp elementor flush-css"
ssh user@host "wp --path=/path/to/wp cache flush"

Proposed Solution

  1. Change invalidateCss() to delete meta fields (set to null) instead of empty string
  2. Add optional SSH config to site definitions in .elementor-cli.yaml:
    sites:
      production:
        url: https://example.com
        username: admin
        appPassword: "..."
        ssh:
          connection: user@host
          wpPath: /path/to/wordpress
  3. After REST API invalidation, if ssh config is present, also run wp elementor flush-css and wp cache flush via SSH
  4. The regenerate-css command should also support the SSH flush path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions