URLresponse is not retrieved after storing in cache using storeCachedResponse

Welcome to the wonderful world of asynchronous caches. NSURLCache is highly asynchronous. Just because you’ve shoved data into it doesn’t mean it is available for retrieval. You have to let the main run loop return before it will be available, and possibly even wait a little while. The failure to return a response immediately after … Read more

Reload the page on hitting back button

header(“Expires: Thu, 19 Nov 1981 08:52:00 GMT”); //Date in the past header(“Cache-Control: no-store, no-cache, must-revalidate”); //HTTP/1.1 This works for me on FF3.6, IE7, IE8, Chrome5 (when hitting browser’s back/forth button the page is always RELOADED) Another solution is to send exactly the same headers sent by session_start() function, very similar to the ones above, but … Read more

caching images served by servlet

The default servlet serving static content in containers like Tomcat doesn’t set any cache control headers. You don’t need write a servlet just for that. Just create a filter like this, public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { long expiry = new Date().getTime() + cacheAge*1000; HttpServletResponse httpResponse = (HttpServletResponse)response; httpResponse.setDateHeader(“Expires”, … Read more

prevent browser back button cache

Thanks guys for helping me out but i found a way that force the browser to prevent cache and i have used the below code : header(“Cache-Control: no-cache, no-store, must-revalidate”); // HTTP 1.1. header(“Pragma: no-cache”); // HTTP 1.0. header(“Expires: 0 “); // Proxies. here is the reference : Making sure a web page is not … Read more