• Resolved yaquawa

    (@yaquawa)


    Hi there, I found that a CORS request make by the fetch seems like won’t trigger the cache to be made?

    I have set the these headers to make sure cors will work

    
    access-control-allow-headers: Authorization, Content-Type
    access-control-allow-origin: *
    

    and in the settings panel I have set “Force Public Cache URIs” to ^/graphql

    yes, it gets a response with 200 status code, but the payload is empty, not even a single letter. I can confirm that the response header with x-litespeed-cache:hit which shows it is a cached response, but with no contents.

    I could confirm that it works if I just copy and paste the request URL made by the fetch to the browser’s address bar(which means it works with the same domain).

    The fetch will send a OPTIONS request before it can send a GET request, so I’m guessing maybe LiteSpeed cached the OPTIONS request instead of GET request..?

    I’m making an API request(GET method) from another domain to an end point of the domain which using this plugin. I want to know if this is a bug or intended?

    • This topic was modified 3 years, 8 months ago by yaquawa.
    • This topic was modified 3 years, 8 months ago by yaquawa.
    • This topic was modified 3 years, 8 months ago by yaquawa.
Viewing 15 replies - 1 through 15 (of 16 total)
  • Hi @yaquawa

    From the behavior you described, it’s possible that the OPTIONS request being cached instead of the GET request. I can tell that from the post, you have the capability to do further digging and troubleshooting. Could you please check the cache plugin log or even the lsws log to figure it out?

    Frankly speaking, we rarely had this scenario happen to us in the past. If you could verify that it would be great.

    Regards,
    Abe

    Thread Starter yaquawa

    (@yaquawa)

    Hi @usabe , thanks for replying!

    I’m not an expert of LiteSpeed Cache, I’m just using a rental server that using LiteSpeed.

    Could you tell me how to setup LiteSpeed Cache to not cache request except GET and HEAD method? (Should I modify the .htaccess?)

    • This reply was modified 3 years, 8 months ago by yaquawa.
    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    by default it only caches with GET request

    you can check source code here

    if ( $_SERVER[ 'REQUEST_METHOD' ] !== 'GET' ) {

    https://github.com/litespeedtech/lscache_wp/blob/v3.6.4/src/core.cls.php#L331

    Best regards,

    Thread Starter yaquawa

    (@yaquawa)

    Hi @qtwrk, thanks for the details!

    Could you reproduce my issue in your environment..?
    Because I have no idea how to solve this, I want to ensure if this is an issue that related to my environment.
    Thanks.

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    you can simply enable the debug log , then see what log says about that request , or why not cached on that request

    Best regards,

    Plugin Support qtwrk

    (@qtwrk)

    Hi,

    I’m going to mark this topic “Resolved”, due to lack of activity.

    If you still need help, please feel free to re-open it.

    When re-open it, please also change the topic status to “not solved”

    Best regards,

    Thread Starter yaquawa

    (@yaquawa)

    @qtwrk

    sorry for the late replying, I have tried output the log, this is what I got.
    Do you see any problems in this log? looks like it was caching the OPTIONS method?

    
    ?? ------OPTIONS HTTP/1.1 (HTTPS) /graphql
    Query String: query=query%20ListContentCategories%20%7B%0A%20%20contentCategories(where%3A%20%7BhideEmpty%3A%20true%7D)%20%7B%0A%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20name%0A%20%20%20%20%20%20slug%0A%20%20%20%20%20%20uri%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%7D%0A&operationName=ListContentCategories&variables=%7B%7D
    HTTP_REFERER: https://localhost:8080/
    User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
    Accept: */*
    Accept Encoding: gzip
    X-LSCACHE: true
    ?? ------OPTIONS HTTP/1.1 (HTTPS) /graphql
    Query String: query=query%20ListContentPosts(%24limit%3A%20Int)%20%7B%0A%20%20contentPosts(first%3A%20%24limit)%20%7B%0A%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20databaseId%0A%20%20%20%20%20%20title%0A%20%20%20%20%20%20date%0A%20%20%20%20%20%20uri%0A%20%20%20%20%20%20featuredImage%20%7B%0A%20%20%20%20%20%20%20%20node%20%7B%0A%20%20%20%20%20%20%20%20%20%20mediaItemUrl%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20contentCategories%20%7B%0A%20%20%20%20%20%20%20%20nodes%20%7B%0A%20%20%20%20%20%20%20%20%20%20name%0A%20%20%20%20%20%20%20%20%20%20slug%0A%20%20%20%20%20%20%20%20%20%20uri%0A%20%20%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20__typename%0A%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20pageInfo%20%7B%0A%20%20%20%20%20%20hasPreviousPage%0A%20%20%20%20%20%20hasNextPage%0A%20%20%20%20%20%20endCursor%0A%20%20%20%20%20%20__typename%0A%20%20%20%20%7D%0A%20%20%20%20__typename%0A%20%20%7D%0A%7D%0A&operationName=ListContentPosts&variables=%7B%22limit%22%3A100%7D
    HTTP_REFERER: https://localhost:8080/
    User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
    Accept: */*
    Accept Encoding: gzip
    X-LSCACHE: true
    [Ctrl] X Cache_control -> stale
    [Ctrl] X Cache_control -> stale
    [Router] get_role:
    [Media] init
    [Router] get_role:
    [Media] init
    [LQIP] init
    [LQIP] init
    [CDN] init
    ? Task init
    [Router] LSCWP_CTRL bypassed empty
    [CDN] init
    ? Task init
    [GUI] init
    [Router] LSCWP_CTRL bypassed empty
    [GUI] init
    • This reply was modified 3 years, 7 months ago by yaquawa.
    • This reply was modified 3 years, 7 months ago by yaquawa.
    Thread Starter yaquawa

    (@yaquawa)

    @qtwrk

    I also tried to find the log you mentioned at here:

    https://github.com/litespeedtech/lscache_wp/blob/v3.6.4/src/core.cls.php#L331

    but I can’t find any text matches [Core] CHK html bypass: not get method, does this means this is a bug?

    Plugin Support qtwrk

    (@qtwrk)

    the log looks like incomplete to me , did you set log level to advance ?

    Thread Starter yaquawa

    (@yaquawa)

    @qtwrk Yes, I have enabled the “advanced” option, and the log is complete.

    Plugin Support qtwrk

    (@qtwrk)

    please create a ticket by mail to support at litespeedtech.com with reference to this topic

    we will investigate further

    Thread Starter yaquawa

    (@yaquawa)

    Plugin Support qtwrk

    (@qtwrk)

    Please use the mail, it will automatically import and create a ticket in our system.

    Thread Starter yaquawa

    (@yaquawa)

    Hi @qtwrk , do you mean [email protected]?
    could you provide me the email address (or maybe the URL of the form?) to send for? Thanks.

    • This reply was modified 3 years, 7 months ago by yaquawa.
    Plugin Support qtwrk

    (@qtwrk)

    yes , that is the mail addr

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘CORS request won’t trigger making cache?’ is closed to new replies.