Forum Discussion

Greywolf_99040's avatar
Icon for Nimbostratus rankNimbostratus
Oct 31, 2011

properly return 304?

Hi, folks, I know this looks "f5-irrelevant" but bear with me a moment.




Problem: Database getting pounded on app cache rebuild


Symptom: Too many connections to database


Desired solution: To have the F5 return a properly crafted 304 response so that the caller understands that his request has not changed, based on a URI, which is taken from an external data file, presumably type "String"




in v9 and v10, I need help on:




* writing a properly crafted 304 response




* constructing an external data file and an iRule that makes use of this data file; if the DB is overloaded, I want the data file to contain a universal match, while if the DB is not overloaded, I want the data file to contain a string that is not likely to match, because in the iRule, if the incoming URI matches the class lookup in the file, it is to send out the properly crafted 304, while if there is no match, the request is simply passed through.




[This was previously listed as "need to test for the existence of a file". Ostensibly it would be cool just to have it send back the content of a file if it exists but not to error out if it DOESN'T exist.]








One Very Confused iRule Student.


5 Replies

  • I need a directive that will let me test for a file



    where is that file located? On the LB or some where else? Furthermore an example for the several cases would help to understand better what you want to do. BTW: you are trying to match ///nomatch/// and /*, but against WHAT are you comparing those strings? The content of a file? I think I'm a bit confused ;-)





    Kurt Knochner
  • Good Day, Kurt, thanks for your reply. It occurred to me that I was not succinct in what I needed, even in my own mind. I have tried to restate the problem as it lies, in hopes it will make more sense.



  • Patrick_Chang_7's avatar
    Historic F5 Account
    iRules do not have access to the file system. However, they do have access to external data groups. You just have to have another process that can write to that file on the F5 system. Please keep in mind that the format of this external data group must be correct and that it has changed between version 9 and version 10 of F5's code. As for constructing a proper 304 message:


    Use HTTP::respond
  • Patrick, thanks, yes, I get all that; however, just placing the following iRule [for testing a 304 response] does not work -- I get "Web page not available"



    when HTTP_REQUEST {


    HTTP::respond 304





    What am I doing wrong, including what am I expecting to happen that is not happening?



    Yes, I am a WebAdmin/f5 NOOOOOOOOOB!


  • Hi Grewolf,



    I would guess that your iRule is working correctly and that the 304's that the iRule is returning are causing your browser to pull the content from Cache.



    I would suggest using a tool like HTTPWatch or Fiddler2 to view the HTTP::status codes that are being returned (they also proved a lot of nice additional information). HTTPWatch has a free version and Fiddler2 is free.



    If you want a shortcut you can just change the status code to a 403 or 500 and verify that the iRule is indeed working.


    when HTTP_REQUEST {
    HTTP::respond 403


    Hope this helps.