Content Caching: Servlet.getLastModified()
Hello everyone,
I've been experimenting the past few days in the process of caching the contents of a servlet response, at the client side, and it was a very frustrating experience. After I was able to get a hold of all the mechanics of this process, I decided to share that information here, to relieve whoever is interested from the mess and frustration I've been through, especially that I haven't found much details on the topic in this forum and on the internet in general.
In case of the GET http method, the default implementation of the service() method uses the getLastModified() method to determine weather the servlet supports the idea of "client-side caching" or not. If getLastModified() returns -1 (which is the default behavior) then the service() method determines that caching is not supported by this servlet, and immediately passes control the the doGet() method, to construct the response for the client.
In order to support content caching, one has to override the getLastModified() method to return the date at which the servlet's-response content has been last modified. When the service() method finds that a positive value is returned by the getLastModified() method, one of the following scenarios would take place.
1-If the request coming from the client doesn't contain the If-Modified-Since header, then the service() method would add the Last-Modified header to the response object, specifying the date when the last content-modification took place, then pass control to the doGet() method. The client would then cache that response, take the value from the Last-Modified header and put it in the If-Modified-Since header in all the requests that follow, to that servlet.
2-If the request coming from the client does contain the If-Modified-Since header with a date EQUAL-TO the one returned by the getLastModified() method, then the service() method responds with a 304 (NOT MODIFIED) status to the client without referring to the doGet() method, and the client should use the cached content. Notice that in this case the service() method would NOT include the Last-Modified header to the response, since the client already knows it.
3-If the request coming from the client does contain the If-Modified-Since header with a date EARLIER-THAN the one returned by the getLatModified() method, then the service() method would add the Last-Modified header to the response object, specifying the date when the last content-modification took place, then pass control to the doGet() method. The client would then cache that response,(which is newer than the one it was already caching) and take the value from Last-Modified header and put it in the If-Modified-Since header in all the requests that follow.
One last thing, when you set the modification date, you HAVE TO round it down to the nearest second ( date / 1000 * 1000), as determined by the time precision in communications over the HTTP: if this process is left out, responses will NEVER be cached.
Edited by: 866769 on Aug 27, 2011 7:40 AM
kinda. you can cache the html output using idocscript. this means your java query only gets executed once every period, say, every half an hour.
but if your java output does not go to a page, like it is some kinda internal processing, then you'll need to figure out some kinda java caching solution.
idoc caching is covered in the manuals, see cacheInclude()
Similar Messages
-
Webinar : Content Caching in Portal Runtime 6.0
<b>SAP NetWeaver Know-How Network Webinar:
Content Caching in Portal Runtime 6.0
Wednesday, 7 July 2004
11 a.m. EDT</b>
On Wednesday 7 July, Ronny Hendrickx, a NetWeaver EP RIG Consultant, hosts the webinar titled <b>Content Caching in Portal Runtime 6.0</b> as part of the ongoing SAP NetWeaver Know-How Network Webinar Series.
Heres how Ron describes his webinar presentation:
This know-how call covers cache functionality in the PRT for SP2 and SP3 (Cache Validator, Cache Discriminator), the API, PRT configuration, and integration with the asyncResponse. Code demonstrations will accompany the various topics.
SDN invites you to post your questions to the presenter prior to the webinar and continue the online discussion afterward.
<b>How to Participate</b>
(Please go to the SDN Events page to see the article and download the PDF presentation)
Dial-in Information:
Date: Wednesday 7 July 2004
Time: 11 a.m. EDT
Within the U.S., call: +1.888.428.4473
Outside the U.S., call: +1.651.291.0618
Password: NetWeaver04
WebEx Information:
Topic: SAP NetWeaver Know-How Network
Date: Wednesday 7 July 2004
Time: 11 a.m. EDT
Meeting Number: 742391500
Meeting Password: netweaver04 (lowercase)
WebEx Link: sap.webex.com
Replay Information:
A recorded replay of this call will be available for approximately three months after the webinar. Access this recording by dialing the appropriate number and using the replay access code: TBD.
Toll-free: +1.800.475.6701
International: +1.320.365.3844
<b>About the SAP NetWeaver Know-How Webinar Series</b>
The SAP NetWeaver Know-How Webinar Series is driven by the SAP NetWeaver Regional Implementation Group (RIG), part of the SAP Development organization. The mission of the SAP NetWeaver RIG is to enable customers, employees, and partners to successfully implement the SAP NetWeaver solution. This SAP RIG has expertise in BI, EP, XI, and WebAS. They contribute their implementation expertise to the SDN implementation forums as well as to the SAP NetWeaver Know-How Webinar Series.
<b>Disclaimer</b>
SDN is not responsible for any changes to the webinar schedule. The webinar schedule may be changed or cancelled without prior notice.this might relate to a bug of the early deploy command versions which allowed deployment only to destinct suborgs (-d), so don't deploy you staff to gloabl (-g option).
/u -
LSO Enterprise Learning - Content Caching
Can someone share their experience and any recommendations related to the Caching of content within the LSO system (including KM).
We have had mixed results with content caching in our testing so I want to know if our results are an anomaly.
Thanks, RandyHi Randy McCormick,
We cache the content centrally, we have tried to work with local caching however that chrashed our Content Player, so we gave up that strategy. Caching centrally has given us some performance issues, but the issues we have faced with local caching was bigger when we tested.
Another thing that we have tested on is running with/without the JSAPI, here our expierence is definitely running WITH the JSAPI setting activated.
If you are able I would like to hear what your expierence is
BR
Jakob -
Hi,
Is it possible to do content caching for the custom component build using java??
Thankskinda. you can cache the html output using idocscript. this means your java query only gets executed once every period, say, every half an hour.
but if your java output does not go to a page, like it is some kinda internal processing, then you'll need to figure out some kinda java caching solution.
idoc caching is covered in the manuals, see cacheInclude() -
The Alteon Personal Content Cache vs cisco cache engine
The Alteon Personal Content Cache vs cisco cache engine
our customer want to deploy cache solution
and want state of art product in current market
can you tell me more in term of 1 perfomance
second current market share.Hi James,
The Alteon Personal Content Cache is Nortel's OEM of the Novell ICS (now called "Volera Excelerator").
This forum isn't really the place to get into discussions of competitive differentiators, but suffice to say that we believe our solution has some significant benefits and features/functionality that the Alteon PCC lacks - for both Transparent Cache (TPC) and Content Delivery (CDN) deployments.
We have details on some recent large "customer wins" in the Content Edge delivery space on the web.
For some of these, see:
http://newsroom.cisco.com/dlls/corp_061801.html
http://newsroom.cisco.com/dlls/corp_041801b.html
There are numerous other examples of these kinds of deployments.
You should contact your Cisco account representative and I'm sure they'd be happy to share more information with you.
cheers,
lincoln. -
How to implement content caching for jsp page ?
Hello everyone,
I am reading an article <Servlets and Jsp Best Practice>,at
http://developer.java.sun.com/developer/technicalArticles/javaserverpages/servlets_jsp/#author, on one section it is saying :
"Cache content: You should never dynamically regenerate content that doesn't
change between requests. You can cache content on the client-side, proxy-
side,or server-side. "
Now I am working on a project. For every user, some of the content servlet generated will be the same for at least a week . I am thinking if I implement caching for these jsp pages, that would increase performace a lot.
But I have no idea how to implement it either client-side or server-side, can someone give me a hint ?
Thanks,
RachelYou mean actually you are caching the response stream
and the key to distinguish between different response
streams are made of user's different request
parameters. And the filter's function is to intercept
the request to see if this request parameter's
combination already exists in the Hashmap,then either
use the cached response or forward to
servlet.....really interesting...Do I get it right ?Yes that's it in a nutshell.
>
Then how do you build those response streams in
advance ? You did it manually or have some mechanism
to build it automatically ?
The data gets cached the first time somebody visits the page.
Find some examples on Filters, and take a look at the HttpServletResponseWrapper class. You need to cache response headers as well as the body. Another pitfall that you might run into is handling an If-modified-since header on the request. Don't cache the results of those requests.
-Jonathan
>
Thanks again !
Rachel -
Controlling Content Cache by Mime Type?
I'm trying to control the application of the "Cache-control" response header based on the mime type of the resource requested. For instance I want to only set it for only static, not dynamic (i.e. JSPs/servlets) content.
Have figured out how to set it for all content by adding the following:
PathCheck fn="set-cache-control" control="private,max-age=3600"
But how can a restrict it to certain mime types such as "image/*" or "application/x-*"?
I suspect an new Object is needed, but can't figure out how to invoke it by mime type:
<Object name="cache-static">
PathCheck fn="set-cache-control" control="private,max-age=3600"
Service fn="send-file"
</Object>
Any help would be apprciated.Unfortunately, you won't be able to use a PathCheck directive. The MIME type hasn't yet been determined when the PathCheck directives execute.
If you're using Sun ONE Web Server 6.1 or later, you could add the following to the default Object:Output type="(image/*|application/x-*)"
fn="set-cache-control"
control="private,max-age=3600" -
Dynamic content in servlets (JDev, iAS)
I build a servlet that print some HTML on output progressively. It looks something like this:
=============================
public void doPost(....)
PrintWriter out = new PrintWriter (res.getOutputStream());
out.println("<html>");
out.println("<head></head>");
out.println("Out1<BR>");
out.flush();
// wait 5 seconds
out.println("Out2<BR>");
out.flush();
// wait 5 seconds
out.println("Out3<BR>");
out.flush();
out.close();
=============================
When I run servlet in JDev (3.2.2), I
saw progress output in my browser, but in
iAS (1.02) I got all content at once.
Probably something is wrong with Apache
configuration. Can you help me?
Thank you
Matic
nullan ias forum was recently added.
you may want to post the question there about the process you're using and what the expected behavior you want is and if it will occur that way in ias.
i'd copy the link to this entry and post it in the ias 9i forum posting if someone wants to look at the code.
i hope this helps ... -
cm:search and content caching and
Hi All,
This is my environment :
Weblogic Portal 8.1 SP3.
Documentum : We are using DCS for connecting to SCS target system and is used as content repository.
If we use <cm:search> as below :
<%
String queryFor25Content = "i_chronicle_id in ('090000058000556e','090000058000487e','09000005800037c3','09000005800195bd','0900000580003116','0900000580011a61','0900000580004365','0900000580003a98','0900000580004299','09000005800030a9','0900000580004793','09000005800043da','090000058000310e','090000058001a622','0900000580021504','0900000580003536','090000058001bc11','090000058001a7bb','09000005800195b5','0900000580003e57','090000058002403c','0900000580023fed','0900000580024065','0900000580023f92','090000058001a971')";
%>
<cm:search id="contents" query="<%=queryFor25Content%>" useCache="true" cacheScope="application" cacheTimeout="300000"/>
<%
int size = contents.length;
for(int i=0; i< size; i++){
Node node = contents;
%>
-----------------Content Start-----------------
<es:notNull item="<%=node%>">
<cm:getProperty node="<%=node%>" name="_content" default="No Content Found"/>
</es:notNull>
-----------------Content End-----------------
<%
%>
In such case, this is my observation:
The content query will not be fired till cache expires.
What I would like to know is that :
Does this also caches the contents that are returned by this query?
As for as my observation is concerned, the content objects are not cached (meaning the binary propery of the content) rather it caches all other attributes of the content.
Can somebody comment on your experiences?. If i have to cache the whole content itself then, should I create my own Cache using "P13N" cache APIs and put the "com.bea.content.Node" in cache??
TIA,
Prashanth Bhat.Hi,
Have you checked the following article?
Content Index status of all or most of the mailbox databases in the environment shows "Failed"
http://support.microsoft.com/kb/2807668
After you create new Active Directory group that is named "ContentSubmitters", please grant Admistrators and NetworkService full access to the group. Then please restart the search services to check result.
Here is a similar thread for your reference.
https://social.technet.microsoft.com/Forums/exchange/en-US/fccf9dca-b865-4356-905b-33ac25dcc44d/exchange-2013-content-catalog-index-failed-all-databases?forum=exchangesvravailabilityandisasterrecovery
Hope this is helpful to you.
Best regards,
Belinda Ma
TechNet Community Support -
Opening the weblocation url of a content with servlet
Hi All,
I tried opening the weblocation url of a webcenter content with a servlet using URL class, but i am getting Gateway timeout(504). But with other urls, the servlet is working fine.
i.e. if i use datacontrol for fetching the content from ucm and if i open the document with the same servlet passing filename and corresponding url as parameters it is opening fine, but if i use RIDC api to get the url and passing the parameters to servlet, the servlet is not working fine
May i know how to open the weblocation url of an ucm content with open/save dialog?
Thanks
S. MuthukumaranCan you describe what you are trying to achieve? (in plain, not technical language) There might be other means to do the same.
My guess is that it is more a timeout issue - see http://www.checkupdown.com/status/E504.html , but I'm really just guessing.
This server did not receive a timely response from an upstream server it accessed to deal with your HTTP request. -
Coherence Help standalone java program put data in cache & Servlet to Read
Hi,
I have coherence 3.4 and using Oracle Application Server 10.1.3 We are in the process of developing a Web Application and want to use Coherence for caching the data. My Coherence is also installed on the same box as Oracle Application Server 10.1.3 need some help in storing the data in the coherence and reading it through the servlet. We have standalone java program that needs to put data in the cache and through servlet want to read that and display it on the page. When running the client the data is stored in the cache but when reading it through the servlet it returns null. We have included both coherence.jar and tangosol.jar in the war file and also in the path when running the standalone java program. Started the Coherence using the below command:
C:\oracle\coherence\lib>java -cp coherence.jar -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml com.tangosol.net.DefaultCacheServer
here is the sample config file used when starting the server above:
<?xml version="1.0"?>
<!DOCTYPE cache-config SYSTEM "cache-config.dtd">
<cache-config>
<caching-scheme-mapping>
<cache-mapping>
<cache-name>VirtualCache</cache-name>
<scheme-name>default-distributed</scheme-name>
</cache-mapping>
</caching-scheme-mapping>
<caching-schemes>
<!--
Default Distributed caching scheme.
-->
<distributed-scheme>
<scheme-name>default-distributed</scheme-name>
<service-name>DistributedCache</service-name>
<backing-map-scheme>
<class-scheme>
<scheme-ref>default-backing-map</scheme-ref>
</class-scheme>
</backing-map-scheme>
</distributed-scheme>
<class-scheme>
<scheme-name>default-backing-map</scheme-name>
<class-name>com.tangosol.util.SafeHashMap</class-name>
</class-scheme>
</caching-schemes>
</cache-config>And here is the standalone java program to put the data in the cache:
import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;
public class PutCache {
public PutCache() {
public static void main(String[] args) {
PutCache putCache = new PutCache();
NamedCache cache = CacheFactory.getCache("VirtualCache");
String key = "hello";
cache.put(key, "Hello Cache123123");
}And here is the Servlet code to read the data but it somehow returns null
import com.tangosol.net.CacheFactory;
import com.tangosol.net.NamedCache;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.*;
import javax.servlet.http.*;
public class Servlet1 extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=windows-1252";
public void init(ServletConfig config) throws ServletException {
super.init(config);
public void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
NamedCache cache = CacheFactory.getCache("VirtualCache");
String value = (String)cache.get("hello");
out.println("<html>");
out.println("<head><title>Servlet1</title></head>");
out.println("<body>");
out.println("<p>The servlet has received a GET. This is the reply.</p>"+value);
out.println("</body></html>");
out.close();
}Is there any other configuration I need. Any help is really appreciated.
ThanksHi,
While starting the coherence using
C:\oracle\coherence\lib>java -cp coherence.jar -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml com.tangosol.net.DefaultCacheServer
while running standaone jave program using the below command
java -Dtangosol.coherence.cacheconfig=C:/oracle/coherence/tests/cache-config.xml Populatecache
In the Web Application don't have any reference to cache-config.xml just using the coherence.jar & tangosol.jar.
What are the steps or configurations I need in order to connect to the same Coherence Cache. Do I need to provide some host:port for the Coherence for storing the data in the cache. How does the java client program and Web Application knows to connect to the Coherence. As currently even if I don't start the coherence server and just run the java standalone program it goes and executes fine wondering wher exactly does it persists the cache if coherence itself is not started or just adding the jars is enough. Any help is appreciated.
Thanks -
How to display the contents of servlet request using the swing component.
I am trying using the servlet to receive the request of the J2ME client. When the request will be there, this should be automatically displayed by the swing User Interface. Again, that component should display the previous requests made alongwith this request.
Shriprasad wrote:
I am trying using the servlet to receive the request of the J2ME client. When the request will be there, this should be automatically displayed by the swing User Interface. Again, that component should display the previous requests made alongwith this request.This makes no sense. Either there's a lot you're leaving out (maybe you're receiving requests on a server, then storing data, and you want to expose the data later via a console of some kind implemented in Swing?), or you don't understand what you're talking about. -
Hi Folks,
My CE is currently running in our network for few days but we encouter some unusual symtoms like;
1) The web broswer will hang with a blank page without displaying any item. After a while, everything will come out instantaneously. For big web page, it hangs longer.
Is this common? Can i fix the CE in such a way where it display the items while itself is pulling data from the origin server?
Any advice is kindly appreciated.
Thanks.Cisco routers support OIR with similar modules only. If you remove a network module, install another module exactly like it in its place. If you remove a 2-slot network module (along with any installed WAN or voice interface cards), install another module and card combination exactly like it.
http://www.cisco.com/en/US/products/hw/modules/ps2797/products_installation_guide_chapter09186a0080227de3.html -
Caching dynamic content?
any one checked out this dynamic content caching engine called
'dynamai'?
customer (ipix.com) claims 35X performance increase and insures no
browser gets stale content....w/o any mods to his existing web
infrastructure.. and he's already on the akamai net.... expects no less
than a 10X ROI in <1yr... just started reading the whitepaper... very
interesting stuff...
http://www.dynamai.com
b.t.I am confused by your comment. But, version 5.1.1 is expected in June with
this feature.
Thanks,
Michael
Michael Girdley
Product Manager, WebLogic Server & Express
BEA Systems Inc
Olivier Brand <[email protected]> wrote in message
news:[email protected]..
Do you know when will be released this version ? Other J2EE compliantservers
like iPlanet 6 offers this tag already. The same product has a cachingmechanism
at the servlet level too. Will you plan to have something similar ? Ifnot, all
the business logic will have to be moved in the JSP page itself, whichdoesn't
follow the path of separating the content from the presentation...
Any idea ?
Olivier
Michael Girdley wrote:
You should also note a new piece of functionality that will be coming
out in
version 5.1.1 (as planned).
This is a special tag extension for JSP that allows you to cache entireJSP
segments/output.
Thanks,
Michael
Michael Girdley
Product Manager, WebLogic Server & Express
BEA Systems Inc
b.t. buxsnard <[email protected]> wrote in message
news:[email protected]..
any one checked out this dynamic content caching engine called
'dynamai'?
customer (ipix.com) claims 35X performance increase and insures no
browser gets stale content....w/o any mods to his existing web
infrastructure.. and he's already on the akamai net.... expects no
less
than a 10X ROI in <1yr... just started reading the whitepaper... very
interesting stuff...
http://www.dynamai.com
b.t. -
Helllo ,
I'm using Jdeveloper 10g ,
I hope If any one can help me in caching static content in my page " Images and CSS and JS libraries "
I use The AFC library and the page cach the static content for the same window , but if I open new window the page will load the static content another time is that " browser caching "
I want to cache this content in the client PC not in page Scope only .
and If I have miss understanding for caching concept I will be owe to you if you give me the correct concept
rgdsHi,
the AFC provides server side caching in that the dynamic parts are not re-build if not required. On the client side its the browser that usually takes care of the content caching
Frank
Maybe you are looking for
-
SQL HELP NEEDED IN QUERY FOR COUNT
I Have this Query SUM (CASE WHEN b.VET_OTHR_ELIG_CDE IN ('02', '03', '04') THEN 1 END) AS VET_YES, SUM (CASE WHEN b.VET_OTHR_ELIG_CDE = '01' THEN 1 END) VET_NO, COUNT (E.ACTV_CDE) AS CNT_ACTV_CDE Now i need to Add two more columns from the same Query
-
Which folder do I use to backup Thunderbird in Windows 8.1
Our previous notebook(which failed)was running Windows 7 and we would copy the 'profiles'folder Our new notebook runs under Windows 8.1 Which folder do we copy (cannot find 'profiles')
-
Upgraded to itunes 8.0 - Purchased Songs now wont play - no error message.
Upgraded to itunes 8.0 - Purchased Songs now wont play - no error message.
-
PO payment term for freight condition separate from payment term in header
Hello, In the PO header we have payment term BB30 (30 days end of month). they are written in the tab 'delivery/invoice'. On item level, we have maintained a freight condition in the tab 'conditions'. With the magnifying loop we have maintained the c
-
Can't load a BFILE into database!
Im "sys", create table lobtest( A NUMBER,B BLOB); INSERT INTO LOBTEST VALUES ( 2, '01010101'); COMMIT; select a,dbms_lob.getLength(b) from dag.LOBTEST; A DBMS_LOB.GETLENGTH(B) 2 4 create directory LOB AS 'c:\bfile'; Then, I created a java file, and l