Hi Keerthika,

Are you using Postman to make the calls? If so we have noticed in a
previous instance that it does not get cached because Postman seemed to
insert unnecessary headers? Can you try using curl requests? Or RESTer is a
handy plugin for firefox.
Or you can set headersToExcludeInHash to the value * and try:
<headersToExcludeInHash>*</headersToExcludeInHash>

Hope it helps.

Regards,
Riyafa

On Mon, Jan 29, 2018 at 2:31 PM, Keerthika Mahendralingam <
[email protected]> wrote:

> Hi All,
>
> I am using the cache mediator in the proxy. But the response is not
> getting cached. I have tested this with EI 6.1.1-update17 and EI
> 6.1.1-update18. For both, the response is fetched from the backend service
> not from the cache. What could be the reason?
>
> I am using the following configuration:
> <?xml version="1.0" encoding="UTF-8"?>
> <proxy xmlns="http://ws.apache.org/ns/synapse";
>        name="connectMockito"
>        startOnLoad="true"
>        statistics="disable"
>        trace="disable"
>        transports="http,https">
>    <target>
>       <inSequence>
>          <cache collector="false" maxMessageSize="1024" timeout="300">
>             <onCacheHit>
>                <respond/>
>             </onCacheHit>
>             <protocol type="HTTP">
>                <methods>GET</methods>
>                <headersToExcludeInHash/>
>                <responseCodes>(1|2)[0-9][0-9]</responseCodes>
>                <hashGenerator>org.wso2.carbon.mediator.cache.digest.
> HttpRequestHashGenerator</hashGenerator>
>             </protocol>
>             <implementation maxSize="100"/>
>          </cache>
>          <send>
>             <endpoint>
>                <address uri="http://demo2236300.mockable.io/testService"/>
>             </endpoint>
>          </send>
>       </inSequence>
>       <outSequence>
>          <log level="full"/>
>          <cache collector="true"/>
>          <send/>
>       </outSequence>
>    </target>
>    <description/>
> </proxy>
>
> * Log for the second call:*
>
> [2018-01-29 14:28:39,010] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "GET /services/connectMockito HTTP/1.1[\r][\n]"
>
> [2018-01-29 14:28:39,011] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "Host: keerthikas-macbook-pro.local:8280[\r][\n]"
>
> [2018-01-29 14:28:39,011] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "Connection: keep-alive[\r][\n]"
>
> [2018-01-29 14:28:39,011] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "Cache-Control: no-cache[\r][\n]"
>
> [2018-01-29 14:28:39,011] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "Content-Type: application/json[\r][\n]"
>
> [2018-01-29 14:28:39,011] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X
> 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132
> Safari/537.36[\r][\n]"
>
> [2018-01-29 14:28:39,011] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "Postman-Token: 48f7595e-3e2c-cee7-9652-
> a82c272b67e2[\r][\n]"
>
> [2018-01-29 14:28:39,012] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "Accept: */*[\r][\n]"
>
> [2018-01-29 14:28:39,012] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "Accept-Encoding: gzip, deflate[\r][\n]"
>
> [2018-01-29 14:28:39,012] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "Accept-Language: en-US,en;q=0.9[\r][\n]"
>
> [2018-01-29 14:28:39,012] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 >> "[\r][\n]"
>
> [2018-01-29 14:28:39,014] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "GET /testService HTTP/1.1[\r][\n]"
>
> [2018-01-29 14:28:39,014] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "Accept: */*[\r][\n]"
>
> [2018-01-29 14:28:39,014] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "Cache-Control: no-cache[\r][\n]"
>
> [2018-01-29 14:28:39,014] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "Postman-Token: 48f7595e-3e2c-cee7-9652-
> a82c272b67e2[\r][\n]"
>
> [2018-01-29 14:28:39,014] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "Accept-Encoding: gzip, deflate[\r][\n]"
>
> [2018-01-29 14:28:39,015] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "Accept-Language: en-US,en;q=0.9[\r][\n]"
>
> [2018-01-29 14:28:39,015] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "Content-Type: application/json[\r][\n]"
>
> [2018-01-29 14:28:39,015] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "Host: demo2236300.mockable.io[\r][\n]"
>
> [2018-01-29 14:28:39,015] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "Connection: Keep-Alive[\r][\n]"
>
> [2018-01-29 14:28:39,015] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
>
> [2018-01-29 14:28:39,015] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 << "[\r][\n]"
>
> [2018-01-29 14:28:39,582] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "HTTP/1.1 200 OK[\r][\n]"
>
> [2018-01-29 14:28:39,582] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "cache-control: no-cache[\r][\n]"
>
> [2018-01-29 14:28:39,582] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "access-control-allow-origin: *[\r][\n]"
>
> [2018-01-29 14:28:39,582] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "Content-Type: application/json; charset=UTF-8[\r][\n]"
>
> [2018-01-29 14:28:39,582] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "X-Cloud-Trace-Context: 4e909d0476e6249930df95cc5b5489
> 9a[\r][\n]"
>
> [2018-01-29 14:28:39,582] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "Date: Mon, 29 Jan 2018 08:58:39 GMT[\r][\n]"
>
> [2018-01-29 14:28:39,583] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "Server: Google Frontend[\r][\n]"
>
> [2018-01-29 14:28:39,583] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "Content-Length: 27[\r][\n]"
>
> [2018-01-29 14:28:39,583] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "[\r][\n]"
>
> [2018-01-29 14:28:39,583] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "{[\n]"
>
> [2018-01-29 14:28:39,583] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> " "msg": "Hello Worldaa"[\n]"
>
> [2018-01-29 14:28:39,583] [EI-Core] DEBUG - wire HTTP-Sender I/O
> dispatcher-4 >> "}"
>
> [2018-01-29 14:28:39,587] [EI-Core]  INFO - LogMediator To:
> http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: ,
> MessageID: urn:uuid:b6b34d4e-e9c0-4228-afb6-54fc74fc2e03, Direction:
> response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><
> soapenv:Body><jsonObject><msg>Hello Worldaa</msg></jsonObject></
> soapenv:Body></soapenv:Envelope>
>
> [2018-01-29 14:28:39,590] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "HTTP/1.1 200 OK[\r][\n]"
>
> [2018-01-29 14:28:39,590] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "access-control-allow-origin: *[\r][\n]"
>
> [2018-01-29 14:28:39,590] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "X-Cloud-Trace-Context: 4e909d0476e6249930df95cc5b5489
> 9a[\r][\n]"
>
> [2018-01-29 14:28:39,590] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "messageType: application/json[\r][\n]"
>
> [2018-01-29 14:28:39,590] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "cacheKey: -83912422-79-114-92-101-8043-
> 26-695-56120-127[\r][\n]"
>
> [2018-01-29 14:28:39,590] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "cache-control: no-cache[\r][\n]"
>
> [2018-01-29 14:28:39,590] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "Content-Type: application/json; charset=UTF-8[\r][\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "Date: Mon, 29 Jan 2018 08:58:39 GMT[\r][\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "Transfer-Encoding: chunked[\r][\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "Connection: keep-alive[\r][\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "[\r][\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "1b[\r][\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "{[\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << " "msg": "Hello Worldaa"[\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "}[\r][\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "0[\r][\n]"
>
> [2018-01-29 14:28:39,591] [EI-Core] DEBUG - wire HTTP-Listener I/O
> dispatcher-6 << "[\r][\n]"
>
> Thanks,
> Keerthika.
> --
> <[email protected]>
> Keerthika Mahendralingam
> Software Engineer
> Mobile :+94 (0) 776 121144 <+94%2077%20612%201144>
> [email protected]
> WSO2, Inc.
> lean . enterprise . middleware
>



-- 
Riyafa Abdul Hameed
Software Engineer, WSO2 Lanka (Pvt) Ltd <http://wso2.com/>

Email: [email protected] <[email protected]>
Website: https://riyafa.wordpress.com/ <http://riyafa.wordpress.com/>
<http://facebook.com/riyafa.ahf>  <http://lk.linkedin.com/in/riyafa>
<http://twitter.com/Riyafa1>
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev

Reply via email to