function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dxjonesdxjones 

How can we change HTTP response headers? (to disable caching)

We are coding a web application integrated with Salesforce.com and we have run into several challenges.

 

One of the obstacles is that, by default, Salesforce.com sets HTTP response headers to allow caching.

 

In our applicaiton, it is a requirement that the HTTP responses must not be cached.

Every request must come to our Salesforce.com application to get a "fresh" result, and to update fields in our database.

It is a disaster if an old (cached) response is used by the remote site.

 

How can we alter the HTTP response headers to force Saleforce.com to disable caching?

 

A typical Salesforce.com HTTP response includes this header line (which is a problem for us):

 

Cache-Control: public, max-age=600

 

A working setup on a server outside Salesforce.com includes these header lines:

 

Content-Length: 308

Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0

Pragma: no-cache

 

How can we force Salesforce.com to output these header lines??

 

-- David Jones

Best Answer chosen by Admin (Salesforce Developers) 
dxjonesdxjones

After some searching, I think this will solve my caching woes:

 

<apex:page cache="false" ...>

 

-- David

 

All Answers

SuperfellSuperfell

Can you provide some more info on exactly which tools / features in salesforce you are using to generate these response.

dxjonesdxjones

After some searching, I think this will solve my caching woes:

 

<apex:page cache="false" ...>

 

-- David

 

This was selected as the best answer