Skip to main content

How to set up Wordpress to use the HTTP cache of Platform.sh

Comments

6 comments

  • Platform.sh DevRel

    Hi,

    I’ve tried this but still get cache miss, I think there maybe something wrong with the Wordpress theme but not sure where to look to try and find what’s stopping it from caching.

    Thanks Dan

    0
  • Justin Phelan

    After installing that plugin I’m getting this message on all pages.

    Warning: Cannot modify header information - headers already sent by (output started at /app/web/wp/wp-admin/includes/class-wp-filesystem-ftpext.php:560) in /app/web/app/plugins/cache-control/cache-control.php on line 359

    0
  • Paul Gilzow

    This will occur if another plugin/theme has caused an error or has sent output to the browser before the cache-control plugin can send the caching-related headers. In your warning message, it references class-wp-filesystem-ftpext.php which indicates something in your set up was attempting to write to the file system. Given the application container on Platform.sh is read-only it would be unable to and fail. In order to determine the root cause, you may want to install the Query Monitor on a local copy or in a development instance.

    0
  • Rachid EL MAHDALI

    Hi,
    I’ve installed a WP instance. Users can’t login, because of a 302 error on login page. It seems to come from this cache issue (x-platform-cache = MISS)
    Since i can’t connect, i can’t tweak this plugin. How can i proceed to activate cache on my website ?

    Thanks
    Rachid

    0
  • Paul Gilzow

    I’ll need some information to help debug your issue. In your .platform/routes.yaml file (docs), what do you have set for <route>:cache:cookies ? Docs.

    For WordPress, it should be something similar to:

    "https://{default}/":
        type: upstream
        upstream: "app:http"
        # Platform.sh supports HTTP caching at the server level. Caching is enabled by default, but is only applied to
        # GET and HEAD requests.
        # More information: https://docs.platform.sh/define-routes/cache.html
        cache:
            # All possible cache configuration options: https://docs.platform.sh/define-routes/cache.html#cache-configuration-properties
            enabled: true
            # Base the cache on the session cookies. Ignore all other cookies.
            cookies:
                - '/^wordpress_'
                - 'wordpress_test_cookie'
                - '/^wp-'
    
    0
  • Paul Gilzow

    I should have asked earlier: is this a single-site-instance WordPress, or a multisite?

    Also, how is your wp-config.php file constructed? Specifically, are you defining WP_HOME and/or WP_URL and if so, what are you using for those values?

    I’m struggling to find a way to access DB with a client like Workbench.

    For that, you’ll need to set up an ssh tunnel.

    Alternatively, you can use the Platform.sh cli tool to get a MariaDB shell on the container using the platform sql command OR if you ssh into your app container, you can use the wp db cli command to get to the same place.

    0

Please sign in to leave a comment.