Caches the specified object, if the corresponding request and response objects indicate that it is cacheable. @param request the request corresponding to the specified compiled script @param response the response corresponding to the specified compiled script @param toCache the object that is to be
(final WebRequest request, final WebResponse response, final Object toCache)
| 173 | * @return whether the response was cached or not |
| 174 | */ |
| 175 | public boolean cacheIfPossible(final WebRequest request, final WebResponse response, final Object toCache) { |
| 176 | if (isCacheable(request, response)) { |
| 177 | final URL url = request.getUrl(); |
| 178 | if (url == null) { |
| 179 | return false; |
| 180 | } |
| 181 | |
| 182 | final Entry entry = new Entry(UrlUtils.normalize(url), response, toCache); |
| 183 | entries_.put(entry.key_, entry); |
| 184 | deleteOverflow(); |
| 185 | return true; |
| 186 | } |
| 187 | |
| 188 | return false; |
| 189 | } |
| 190 | |
| 191 | /** |
| 192 | * Caches the parsed version of the specified CSS snippet. We key the cache based on CSS snippets (rather |