304 If-modified-since

The following seems to be doing what it should i.e. comparing a modified-since header against a database value and sending a 304 if not modified accordingly. It appears to work but I would like your comments since I'm new to doing this type of thing.
void doConditionalGet(java.sql.Timestamp ts, HttpServletRequest request,
HttpServletResponse response) {       
        response.setDateHeader("Last-Modified", ts.getTime());
        long modifiedSince = -1;
        try {
            modifiedSince = request.getDateHeader("If-Modified-Since");
            if (modifiedSince != -1 && modifiedSince >= ts.getTime()) {               
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                return;
        } catch (IllegalArgumentException iae) {
            log.error(iae);
    }Thank you
Niklas

The following seems to be doing what it should i.e. comparing a modified-since header against a database value and sending a 304 if not modified accordingly. It appears to work but I would like your comments since I'm new to doing this type of thing.
void doConditionalGet(java.sql.Timestamp ts, HttpServletRequest request,
HttpServletResponse response) {       
        response.setDateHeader("Last-Modified", ts.getTime());
        long modifiedSince = -1;
        try {
            modifiedSince = request.getDateHeader("If-Modified-Since");
            if (modifiedSince != -1 && modifiedSince >= ts.getTime()) {               
                response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                return;
        } catch (IllegalArgumentException iae) {
            log.error(iae);
    }Thank you
Niklas

Similar Messages

  • Using the if-modified since http header

    I've a few questions regarding this header.
    1/ What is the point in using this header? Does it help with page ranking/hits?
    2/ Is if useful for static html pages or just for dynamic ones?
    3/ If it is useful for static pages, how do you add it? I.e exactly what code needs to added to the header? There seems to be quite a lot of discussion on the web about the merits or not of using this, but no examples of what code needs to be added.
    Any ideas?

    I hacked the Servlet myself so that it honors the if-modified-since header and returns HTTP-304 if the cached version is still ok.
    lg Clemens

  • If-modified-since header?

    Google tells me I need to be hosted on a server that supports this header (and it makes sense from a Google perspective). My host tells me that his servers do support that header. Yet when I test my pages on his server, the tool I am using tells me no support. Can anyone here help me with this?

    OK - for this to work, you need to insert a preamble on each PHP page -
    <?php
    $tsstring = gmdate('D, d M Y H:i:s ', $timestamp) . 'GMT';
    $etag = $language . $timestamp;
    $if_modified_since = isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $_SERVER['HTTP_IF_MODIFIED_SINCE'] : false;
    $if_none_match = isset($_SERVER['HTTP_IF_NONE_MATCH']) ? $_SERVER['HTTP_IF_NONE_MATCH'] : false;
    if ((($if_none_match && $if_none_match == $etag) || (!$if_none_match)) &&
    ($if_modified_since && $if_modified_since == $tsstring))
    header('HTTP/1.1 304 Not Modified');
    exit();
    else
    header("Last-Modified: $tsstring");
    ?>
    This is from the discussion here -
    http://stackoverflow.com/questions/1971721/how-to-use-http-cache-headers-with-php
    which I had seen once, but it was not clear to me that this was to be used on the pages involved, and thought it might be a way to check the if-modified-since header from a PHP page instead of a way to make the page send the header.

  • If-Modified-Since HTTP Header

    Does anyone know if BC supports the if-modified-since http header? If it doesn't - how to add it to a BC webpage?
    In google guideline for SEo it states:
    Make sure your web server supports the If-Modified-Since HTTP header. This feature allows your web server to tell Google whether your content has changed since we last crawled your site. Supporting this feature saves you bandwidth and overhead.
    Thanks.

    I hacked the Servlet myself so that it honors the if-modified-since header and returns HTTP-304 if the cached version is still ok.
    lg Clemens

  • ??? Using JSPs to Send Not-Modified-Since Header ???

    Hi all,
    In looking at past posts, I'm afraid I know the horrible answer
    to this issue but I thought I'd ask just in case I missed
    anything.
    Let me start by saying I'm using Tomcat v4.0.4 beta 3.
    As you know, when a client (usually a web browser) has a cached
    version of a resource (usually a web page) it can send an
    "If-Modified-Since" header to the HTTP server. The server
    compares the time/date stamp specified in the header with that of
    the requested resource. If the resource has not been modified
    since the time specified in the "If-Modified-Since" header, the
    server sends back a 304 (Not-Modified) response, effectively
    telling the client (usually a web browser) that its cached
    version of the resource is still valid.
    When writing a servlet, it's easy to handle this sort of
    scenario. The javax.servlet.http.HttpServlet class has a
    "service()" method. This method first checks if the incoming HTTP
    method is a GET. If it is, the "service()" method proceeds to
    call the "getLastModified()" method of the servlet. As a
    developer, you can override "getLastModified()" to return a long
    value representing the last time the requested resource was
    changed. Depending on the value returned by "getLastModified()"
    (note that -1 is returned if you don't override the method) the
    "service()" method may simply return a 304, Not-Modified response
    rather than calling the servlet's "doGet()" method.
    Now, the $18.32 Question: How do you ensure "getLastModified()"
    is called in JSP?
    No, you cannot simply do this:
    <%!
       public long getLastModified() {
          return xxx;
    %>The problem is that the above method will never be called by the
    container.
    I traced through some of the Tomcat/Catalina/Jasper code and it
    seems to me that the response code is being set to 200/OK very
    early on in the processing.
    I also took a cursory look at the JSP spec and didn't find any
    indication of setting a "Not-Modified" response code...so, I am
    thinking this is something that is (strangely) missing in the JSP
    specification. I have a JSP page that needs to update itself once
    per day. Therefore, it would be very handy to have the
    "getLastModified()" functionality enjoyed by servlet writers.
    Can anyone confirm this?
    Thanks...

    I've not come across this before, but like you I cannot find any mention of how to handle modification dates in the JSP spec. I can think of a couple of possible ways round this:
    1. Try to delegate the functionality to a servlet. You'd need to pass the JSPs modification date and handle the return. Seems messy and I haven't tried it.
    2. Add code to the JSP to read the headers directly and set the appropriate status code. e.g. at start of JSP:
    <%@page  import="java.util.*" %>
    <%
    if (request.getMethod().equals("GET")) {
       GregorianCalendar lastModified = new GregorianCalendar(2002, 01, 01); // use constant for testing
       response.setDateHeader("Last-Modified", lastModified.getTimeInMillis());  //always set header
       long modifiedSince = -1;
       try {
          modifiedSince = request.getDateHeader("If-Modified-Since");
       } catch (IllegalArgumentException iae) {
            // System.out.println(iae);
       if (modifiedSince != -1 && modifiedSince > lastModified.getTimeInMillis()) {     
          response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
          return;
    %>This would probably best be implemented as a custom tag if needed in more than one page.

  • Safari seems not sending If-Modified-Since header for main address

    Not sure I'm in the appropriate forum but let's try (if there is more appropriate one please advise).
    When Safari requests a resource (page, image...) to a web server it doesn't provide If-Modified-Since header for the main resource of the request. That means the web server can't answer "resource not modified, use your cache". This is not the behavior of other browsers and not good in terms of performance for the web server as well as for the user.
    However Safari sends this If-Modified-Since for the sub-elements of the resource (e.g. images, css in a page...). Which is good.
    Is there a way to influence Safari's behavior to provide a If-Modified-Since for the main resource requested to the server?
    acama,

    Found out the answer.  IIS 6 does in fact steal "If-Modified-Since" and "If-None-Match" headers, but only on custom 404 redirects.  That's actually what I'm doing here (that'll teach me not to put details in a question when I think they're irrelevant -- actually I just forgot).
    Here's two discussions on the issue (they're using ASP, but apparently it's the same for ColdFusion):
    http://www.eggheadcafe.com/conversation.aspx?messageid=32839787&threadid=32839787
    http://www.webmasterworld.com/microsoft_asp_net/3935439.htm

  • GetHttpRequestData missing "If-Modified-Since" and "If-None-Match"

    I'm using CF8 on IIS6/Win2003 Server.
    In my cfm I have:
    <cfset reqheaders=GetHttpRequestData().headers>
    <cfdump var="#reqheaders#">
    ...which gives:
    struct
    Accept
    text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Charset
    ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Accept-Encoding
    gzip,deflate
    Accept-Language
    en-us,en;q=0.5
    Cache-Control
    max-age=0
    Connection
    keep-alive
    Cookie
    CFID=[removed]; CFTOKEN=[removed]
    Host
    [my test server]
    Keep-Alive
    300
    User-Agent
    Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3
    But if I look at the actual headers being sent from my browser (using Firefox LiveHTTP add-on), it shows I am sending "If-Modified-Since" and "If-None-Match" headers.
    GET /path/to/cfmfile.cfm HTTP/1.1
    Host: [removed]
    User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.6) Gecko/2009011913 Firefox/3.0.6
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
    Accept-Language: en-us,en;q=0.5
    Accept-Encoding: gzip,deflate
    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
    Keep-Alive: 300
    Connection: keep-alive
    Cookie: CFID=[removed]; CFTOKEN=[removed];
    If-Modified-Since: Fri, 18 Sep 2009 01:18:19 GMT
    If-None-Match: ""0134E50193C69AD753656B0513FCB28C""
    Cache-Control: max-age=0
    Is there some reason IIS would "steal" those headers before handing over control to ColdFusion?  Or does GetHttpRequestData sometimes "miss" headers?  Other ideas?  Is there any other way I can get at the raw HTTP request from within ColdFusion?
    I'm at a loss.  Others have used the same process and no one seems to have this issue.
    (see: http://www.petefreitag.com/item/235.cfm or http://admin.mxblogspace.journurl.com/?mode=article&entry=1853 for examples)
    I've tried accessing the page using Internet Explorer instead.  It also is not showing those headers, but I have not sniffed IE's actual headers being sent so I can't be sure those headers are included (but I think they are, since IE implements conditional GET).

    Found out the answer.  IIS 6 does in fact steal "If-Modified-Since" and "If-None-Match" headers, but only on custom 404 redirects.  That's actually what I'm doing here (that'll teach me not to put details in a question when I think they're irrelevant -- actually I just forgot).
    Here's two discussions on the issue (they're using ASP, but apparently it's the same for ColdFusion):
    http://www.eggheadcafe.com/conversation.aspx?messageid=32839787&threadid=32839787
    http://www.webmasterworld.com/microsoft_asp_net/3935439.htm

  • Verify that MBR hasn't been modified since last boot / overwrite it

    I need a way to check if the MBR and /boot partition have been modified BEFORE the system boots and if so, a way to overwrite them with "trusted" backups, again BEFORE the system boots.
    Is it possible to accomplish this by booting SOME SYSTEM (which one?) from a thumb drive, that checks the MBR and /boot partition for modifications and tells me if they have been modified and, ideally, offers to overwrite them with previosly stored, trusted versions?
    I searched the whole internet ... didn't find anything useful
    PLEASE HELP ME
    Edit:
    I know that this can be accomplished by booting some Live-CD and doing all manually. But it should be as minimal as it gets.
    Something like: It boots from thumb drive(sdb), checks MBR and boot partition of sda and if they haven't been modified since last boot, it should "chainload" the normal bootloader on sda.
    I don't want to mess around with assembler though.
    Last edited by FinallyHere (2011-03-16 10:51:03)

    What I would do is get the smallest linux distro I can find (or use LFS to make one) and make a bootable usb stick out of it (maybe with unetbootin.) Then it should be easy enough to write a script that uses dd and diff (and maybe md5sum to speed things up) to compare the boot sector and /boot and offer to rewrite them if necessary... And launch grub to boot from sda. The script could be launched automatically before login by tweaking the init scripts or running it as a daemon.
    Not a ready-made solution, and I don't know how scriptable grub really is, but since there was no answer yet...

  • ERROR: Page is modified since you opened it!!

    Hi All,
    I have inserted  sharepoint 'view' in page and in another page i have called that page using ajax call with custom filter vales, so the view has been displayed without any problem.
    Now the problem is when i click the column name in the 'view' to 'sort' or 'filter' the page refreshes and throws the "ERROR:The page is modified since you opened it". I have tried this solution 
    <script language=”javascript” type=”text/javascript”>
    if(document.getElementById(“MSO_PageHashCode”))
    document.getElementById(“MSO_PageHashCode”).value=”";
    </script>
     but didnt work for me.
     Any other solution i need to try?

    Hello,
    Check the below blog:
    https://wordimpress.com/sharepoint-errors-warnings-and-problems-collection/ 
    Error: This Page has been modified since you opened it. You must open the page again.
    Solution: If this is continually happening while editing a page using the browser the page may be detached from the page layout. Open SPD and reattach the page to its page layout.
    Also check this if you have set the PostBackUrl of a LinkButton to the DefaultViewUrl of a list. 
    Solution: Using a HyperLink and setting the NavigateUrl to the DefaultViewUrl resolved the problem.
    Please remember to click Mark as Answer on the answer if it helps you.
    Cheers, Keerth
    Keerth R

  • OS X says that Compressor was modified since the code sign and won't let me launch it. Any reasoning behind this?

    Hello
    After updating Compressor to the most recent version (4.2), I get a message saying that Compressor was modified since the code sign and then won't let me launch it.
    I have tried reinstalling Compressor restarting and updating my computer.
    Any reasoning behind this problem??
    Thanks
    I am running OS X Yosemite 10.10.3 on a 2013 13inch MacBook Pro, 8GB RAM, 2.8GHz i7.

    Start the computer from the installation disk and perform Repair Disk and Repair Permissions using Disk Utility

  • External component modified since last VI save

    Hi !!
    it's been quite a bit that I'm stuck with this message "External component modified since last VI save". One explanation on the forum does not solve my problem.
    The problem is :
    I have a simple VI (enclosed) that I open on two different computers. Each time I save it on one computer and I open it on the second one Labview shows the mysterious message "External component modified..."... and I have to save the VI... Back to the first computer - same thing...
    Does anyone know where should I search to get rid of this message ?
    Thanks for any suggestions...
    Attachments:
    external_component_mod.vi ‏8 KB

    Yes, references are opened and closed the same way...
    In fact my problem is summarized in the VI I enclosed in my first post... There's one computer that has a different configuration from others here, and when I open that Vi on that computer Labview asks to save it before close (external component modified). I've checked the OS, the Excel version, ...

  • TestStand API External Component Modified Since Last VI Save

    I'm using TestStand 3.5 with LabVIEW, and deploying my code across multiple stations.  The code is managed by Perforce (source code control).  I'm keeping the stations identical by installing NI software from the same CDs (which I'll refer to as an "Original Station"), but it seems that over time the TestStand API will somehow be externally modified ("Modified Station"), which causes LabVIEW to recompile the VI.  The Explain Changes dialog box states "VI recompiled.  External component modified since last VI Save."  If I save the recompiled changes on a Modified Station and submit the changes, an Original Station opening the VI will then recompile VI, stating that an external component has been modified since the last VI save.  If I resave the VI on an Original Station, then the next time I open it on a Modified Station the recompile will occur.
    This is problematic, because there will be a performance hit if LabVIEW has to recompile when opening VIs.  In addition, it makes debugging difficult, because LabVIEW will prompt to save changes on all the VIs if they were saved on a different station state.  Not to mention the unnecessary copies made in the source code control to maintain the history of the recompiling.
    My current solution is to reinstall TestStand on all the Modified Stations.  I set any TestStand strict typedefs that I use to non-strict typdefs, mass compile the TestStand addon folder in vi.lib, and then the station becomes an Original Station again.  Overtime, it will modify itself and turn into a Modified Station.  Since these stations are at multiple sites, it is very inconvenient to manage.
    My questions are the following:
    1. What is causing this external modification?  Is there anyway to prevent it, so that the installation and code will not get modified so that all will remain Original Stations?
    2. If it is not preventable, how can I force all stations to become a Modified Station, so at least they are all the same?
    I've attached LabVIEW 8.5 VIs that demonstrate the VI differences.  I've observed this behavior in LabVIEW 7.1 and 8.2 previously.  If anyone also experience this behavior or has a work around, please post to this thread.  If NI has insight on what is causing this behavior and how to prevent it, it will help me out greatly.
    Thanks!
    Attachments:
    test_recompile_original_lv85.vi ‏7 KB
    test_recompile_modified_lv85.vi ‏7 KB

     Wilbur,
    Do you have more than one version of TestStand or LabVIEW on the stations?   Switching the active version of TestStand changes the registered version of the TestStand API which I believe is the external change that forces a recompile.  If version switching is the cause of the problem you could prevent these changes by not sharing any TestStand VIs between different versions of TestStand.  If each version of TestStand has its own VIs then a VI is compiled against one and only one engine version.
    -Rick Francis

  • How can I search and find all files modified since december 1st 2010

    I just want to see all the files that have been modified on my Windows Server 2008 since December 1, 2010.  I want to see if there is anything unusual.  Is this possible without 3rd party software?
    I support 2 Windows Server 2008.  On one of them, I can't seem to get any advanced search options until I type at least one character in the name of the file I am searching for (but I want to search all files).  Even then, the search is slow, it
    tells me it did not bring back all results because there are too many and the results window is too awkward to navigate.  On the second server, when I click in the search box, it has buttons I can click, one is "Date Modified" but they only have predefined
    options like "Last week" and "yesterday".
    Every version of windows explorer gets worse and worse at searching.  I rarely use it anymore.  I usually install "Search Everything" from voidtools.com.  You can download, install, index, and search and get your results all more quickly than
    finding the results in windows explorer.

    Hi,
    It should be caused that Windows Search is not installed on the second server. See following steps to install it:
    1) Start Server Manager
    2) Click on Roles in the left navigation pane
    3) Select Add Role in the Roles Summary pane to the right
    4) Select the File Services role and click Next
    5) Select the Windows Search role service and Finish the wizard.
    Meanwhile, when you search for a file such as "data", input keyword data and click the Advanced Search at the bottom to result box. Then you can select "Data and modified" and "is after" December 1, 2010
    Shaon Shan |TechNet Subscriber Support in forum |If you have any feedback on our support, please contact [email protected]

  • 304: not modified warning

    Using a MS Soap Toolkit 2.0 gold client to access a web service on 6.1b gives a
    304 error, whereas a java client (weblogic's Client and DClient) works perfectly.
    There must be a difference in the soap get header thats being created by the
    two different clients.
    So, anyone know where anywhere I can get hold of the details/source code of the
    weblogic soap.WebServiceProxy and weblogic.soap.SoapMethod classes to see that
    they are doing correctly so that we can replicate this for the ms client!
    Thanks

    I have the same issue except mine would not load immediately to a blank screen.  The browser would sit and spin for as long as you let it.  Bypassed fast.fonts.net and CNN.com came right up.  Having the same issue on other sites as well not related to the above site.  Some sites load fine but when you click on a link on the site, white background and just sits and spins.  Absolutely no information in any logs.  This is annoying.  Works in in all other browsers and on mobile devices.  Issue is only related to IE that I can see.

  • WLS support for SC_NOT_MOFIDIED (304) status code

    Hi all,
    We are using WLS 7.0 and noticed that it does not support the conditional retrieval
    of URL for static content (ie html pages and gif files etc). This is true at least
    for web application deployed with either a war file or "exploded" directory structure.
    For those of you who not familiar with this status code, it basically enables
    browser to send IF-MODIFIED-SINCE header with a http request. The server is supposed
    to check if a new version exisits and if not, returns status code 304. This would
    speed up things for an application with large number of static images, css or
    html files. We are quite surprised that a leading product like WLS would omit
    somthing so basic. So we are not sure if there is a place to turn it on or off?
    If there is simply no support for this feature, can someone provide some explaination
    as to the rationale behind it? We have some idea, but would rather hear it directly
    from BEA. Thanks.

    No, we have consolidated on the Apache XML/XSL stuff. You are free to use
    whatever other parser you would like however. The Sun XML pkg should work
    fine.
    Thanks,
    Michael
    Michael Girdley
    BEA Systems Inc
    "Boris Tabenkin" <[email protected]> wrote in message
    news:[email protected]..
    Are you still including the sun XML package, and if so which version?
    "Toby Allsopp" <[email protected]> wrote in message
    news:[email protected]..
    Hi, Craig.
    Craig Macha wrote:
    Our company typically does NOT use Open Source products. We can't
    risk
    not having support.
    I think you're a little confused about what "Open Source" means. Itdoesn't mean "unsupported." If you want support then you need to pay forit,
    just like any software. One of the advantages of open source software is
    that you aren't tied to a single vendor for your support - anyone with the
    appropriate skills can take the source code and
    provide support, as BEA have chosen to do in this case.
    Regards,
    Toby Allsopp.

Maybe you are looking for