• Resolved tenderfeel

    (@tenderfeel)


    Hello,

    Wordpress is on Amazon Web Services and uses a custom domain.
    An example is shown below.

    Wordpress URL (AWS)
    https: //***.ap-northeast-1.elb.amazonaws.com/

    Request URL
    https://example.com/wp-json/custom/v1/***

    Custom domain requests are not cached.
    Entering the AWS URL directly into the address bar was cached.

    https: //***.ap-northeast-1.elb.amazonaws.com/wp-json/custom/v1/***

    Is there a way to enable caching when requested on a different domain than the installation URL?
    Or do you have any plans to support it in the future?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @tenderfeel

    Thank you for using our plugin!

    I just did some tests, I installed WordPress locally on example.local and also made it available on somethingelse.local. I then did some REST requests on somethingelse.local and those requests were cached as expected.
    I even double checked our code and there is no reason why the requests wouldn’t be cached, we don’t look at the url, only at the request path (i.e. /wp-json/custom/v1/***).

    What makes you say it isn’t cached? How did you check this?

    Thread Starter tenderfeel

    (@tenderfeel)

    Thank you for the verification.
    I’ve read the source of the plugin since then and understand that it only uses the request path when storing the cache.

    The plugin cache works when accessing the endpoint on the same domain as the WordPress admin screen, but otherwise it doesn’t work no matter which domain you access.

    I added var_dump to various parts of the plugin to verify where it stopped working.

    1. sources/wp-rest-cache.php (Line 25)
    2. wp-rest-cache.php (Line 41)
    3. class-plugin.php (Line 123)
    4. class-plugin.php (Line 140)
    5. sources/wp-rest-cache.php (Line 28)
    6. class-endpoint-api.php (Line 292)

    I entered the URL of the endpoint directly into the Chrome address bar and checked if the var_dump string was displayed with the response JSON.

    In the case of a domain on the admin screen, all six logs will be displayed.
    In the case of other domains that include a display domain, only 2 to 4 will be displayed.
    Locally, all but 1 and 5 are displayed.

    The server configuration is said to look like this.

    ???♂?User

    CloudFront
    → Load Balancer → Nuxt.js Server(EC2)
    → Load Balancer → WordPress Server(EC2) → MySQL ← WordPress Admin(EC2)

    Basic authentication is used for the development environment.

    Will it be a solution hint?
    I will continue to look into the cause….

    Plugin Author Richard Korthuis

    (@rockfire)

    Hi @tenderfeel

    Thank you for your clear description of what you already did! You are talking about var_dump’s in sources/wp-rest-cache.php, just to be sure (I am not sure if you are aware of it): this file is copied to /wp-content/mu-plugins upon plugin activation. So if you want your var_dump’s to work you would have to put them in /wp-content/mu-plugin/wp-rest-cache.php.

    You say for the other domains only 2 to 4 are displayed, this almost sounds like the must use plugin isn’t loaded, which would be very strange and something out of our control, since it is WordPress core functionality. My guess it you would have to focus on that part, the loading of the /wp-content/mu-plugin/wp-rest-cache.php.
    Either that file isn’t loaded OR WordPress is at this point saying the WP REST Cache plugin isn’t active.

    Plugin Author Richard Korthuis

    (@rockfire)

    This thread has been marked as resolved due to lack of activity.

    You’re always welcome to open a new topic.

    Thanks for understanding!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Issue with using Amazon Web Services’ is closed to new replies.