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
ScriptMonkeyScriptMonkey 

How do you cancel Cache="true" before the expires time hits?

We have a page that has a cripplingly slow generation time, so we have caching set to one day on a page.

 

<apex:page cache="true" expires="86400">

 We just made a major modification to one of the aspects of this page that uses an ajax call.  The values that are returned by this ajax call are not readable by the previous version of the visual force page's javascript.  This is the problem we're facing.  Elaborated more:

 

If we install the new package, the visualforce page is still going to be cached for 24 hours, but the ajax responder will send data it can't read, until the caching is over and the new version of the visualforce page is there.

 

Is there a way to cancel a web page's caching in sites?  We tried changing the site, changing the cache to false, even deactivating the site, and none of those things had any effect until the caching ran out.

 

Any advice would be welcome.

Best Answer chosen by Admin (Salesforce Developers) 
aballardaballard

That's how caching works.  The server that has cached it is not going to contact the SF server, so how can it possibly find out that you want to change it.  

 

The usual approach to this kind of issue is to reduce the cache timeout period some time before you make the change, perhaps in stages if you can't take the performance hit.   e.g. 24 hours before you are going to change it, reduce the timeout to 12 hours.   12 hours before, reduce it to 1 hour, 1 hour before reduce it to 10 minutes or something like that. 

 

The only alternative I know of is to change the name of the cached object.   If this is a page, that probably doesn't work for you.