You need to sign in to do that
Don't have an account?
Sujata Tiwari 3
how to set cache control at header level in web service?
Hi,
I tried doing this :
request.setHeader('Cache-Control','public,max-age=43200');
but still when I checked response in rest api. I can't see my value at max-age, it's still displaying like this :
Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private
Please help me with this on how to proceed further on the same.
Thanks in advance..!!
I tried doing this :
request.setHeader('Cache-Control','public,max-age=43200');
but still when I checked response in rest api. I can't see my value at max-age, it's still displaying like this :
Cache-Control: no-cache,must-revalidate,max-age=0,no-store,private
Please help me with this on how to proceed further on the same.
Thanks in advance..!!
Thanks for your rpl. I tried this :
RestResponse res = RestContext.response;
//httpResponse response = new httpResponse();
res.setHeader('Cache-Control','public,max-age=43200');
But the above code is throwing some error :
Method does not exist or incorrect signature: void setHeader(String, String) from the type System.RestResponse.
Please help me with the same.
Thanks
If you are using httpResponse() then try the below code
Thanks for your help.
But it is working perfectly for me. Instead of setHeader I used addHeader() and it worked.
Appreciate your response..!!:)