• Force Browser Refresh

    Author
    Topic
    #408570

    I’m working on a project that involves outputting PDF directly to the screen and it works! but only if I remember to hit the ‘refresh’ button. how does one make the page do this automatically?

    I know there’ s simple stuff like using META tag for refresh and javascript document.location.reload(true); but those aren’t working for my set up.

    the odder thing about what I am doing is, the PDF is generated in Memory and displayed to the browser directly as a binary image, so there’s not a URL to reference, which means the META tag solution (from what I can tell) won’t work.

    I also have s sneaking suspicion that no matter what I do some browsers, because of settings, will not listen to some javascript code that tells it to refresh.

    However, perhaps I am wrong on that clown

    Anyhoo, does anyway have a quick solution? I’m thinking some kind of javascript that kicks in after OnLoad() or some such.

    I’ll keep poking around, but thought I’d give the loungers a try.

    TIA
    compute

    Viewing 3 reply threads
    Author
    Replies
    • #863688

      Some browsers don’t have javascript enabled-so your sneaking suspicion is certainly correct.

      • #863690

        that’s not an issue – the pages i am working on are for people in my area so I will be able to demand, force, and foist javascript on them.

        • #863815

          Can you use window.setTimeout() ? It is one that is abused, so will not fire under many pop-up blockers…

          On second thought: if the image resides in memory, and you refresh the page, don’t you lose the image? This is not making a great deal of sense to me.

        • #863816

          Can you use window.setTimeout() ? It is one that is abused, so will not fire under many pop-up blockers…

          On second thought: if the image resides in memory, and you refresh the page, don’t you lose the image? This is not making a great deal of sense to me.

      • #863691

        that’s not an issue – the pages i am working on are for people in my area so I will be able to demand, force, and foist javascript on them.

    • #863689

      Some browsers don’t have javascript enabled-so your sneaking suspicion is certainly correct.

    • #866372

      I’m coming in a little late, and I’m not sure if you’re running into this issue, but with generated web content, IE can be a pain. It has a habit of using its cache even when you tell it not to. But to make sure we’re tackling the right issue, can you answer a couple questions:

      1) What are you using to generate the binary image for the PDF (is it done with ASP, JSP, Java Servlet, DLL, etc.)?

      2) What’s the URL to access the script or app that creates the PDF in memory?

      3) What happens if you change the browser’s cache setting (Tools > Internet Options > Temporary Internet Files > Settings > Check for newer version of web pages = Every visit to the page)?

      4) Are you setting the content type header in the response that sends the PDF? Expiration? No-cache?

      Knowing this stuff helps narrow down the problem and getting the right solution.

      Thanks

      • #866522

        since posting my question, I accidentally deleted the entire directory for the project I was working on and have had to re-write it, and in the course of doing so have implemented things differently so the whole issue of forcing the browser to refresh no longer applies.

        FYI, I am using a server object called ActivePDF Toolkit that allows you to create PDFs on the fly or populate a PDF template with data from a db and lots of other things. My first shot at making it work used some code that creates a new unique file each time a PDF is generated; I switched to generating the PDF in memory and that’s when the Refresh issue came up.

        Now I’m just overwriting the output file and displaying it using response.redirect, which works just fine.

        Thanks for your suggestions, but IMHO certain things (like depending on predictable caching behaviour from a browser) are just asking for trouble. I was always sceptical that a particular technique for refreshing the browser would work cross-platform.

        OTOH, I don’t even know *why* I was having the problem I was having: 1. create the pdf in memory and 2. output to the browser using application:x-pdf (or however the content type header is specified)…. in IE nothing happens unless you hit F5 and then the in-memory generated PDF shows up. weird. My current method makes more sense to me.

        anyway, thanks for replying.

        • #866529

          Well, deleting the project is one way to go. A bit extreme. ; -)

          I don’t think it’s so much forcing refresh as much as forcing IE not to read it’s cache. In some cases we’ve had to add a querystring with timestamp parameter to force IE to actually get the file instead of reading it back from memory.

          Hopefully overwriting the output works without any new snags.

          Good luck.

        • #866530

          Well, deleting the project is one way to go. A bit extreme. ; -)

          I don’t think it’s so much forcing refresh as much as forcing IE not to read it’s cache. In some cases we’ve had to add a querystring with timestamp parameter to force IE to actually get the file instead of reading it back from memory.

          Hopefully overwriting the output works without any new snags.

          Good luck.

      • #866523

        since posting my question, I accidentally deleted the entire directory for the project I was working on and have had to re-write it, and in the course of doing so have implemented things differently so the whole issue of forcing the browser to refresh no longer applies.

        FYI, I am using a server object called ActivePDF Toolkit that allows you to create PDFs on the fly or populate a PDF template with data from a db and lots of other things. My first shot at making it work used some code that creates a new unique file each time a PDF is generated; I switched to generating the PDF in memory and that’s when the Refresh issue came up.

        Now I’m just overwriting the output file and displaying it using response.redirect, which works just fine.

        Thanks for your suggestions, but IMHO certain things (like depending on predictable caching behaviour from a browser) are just asking for trouble. I was always sceptical that a particular technique for refreshing the browser would work cross-platform.

        OTOH, I don’t even know *why* I was having the problem I was having: 1. create the pdf in memory and 2. output to the browser using application:x-pdf (or however the content type header is specified)…. in IE nothing happens unless you hit F5 and then the in-memory generated PDF shows up. weird. My current method makes more sense to me.

        anyway, thanks for replying.

    • #866373

      I’m coming in a little late, and I’m not sure if you’re running into this issue, but with generated web content, IE can be a pain. It has a habit of using its cache even when you tell it not to. But to make sure we’re tackling the right issue, can you answer a couple questions:

      1) What are you using to generate the binary image for the PDF (is it done with ASP, JSP, Java Servlet, DLL, etc.)?

      2) What’s the URL to access the script or app that creates the PDF in memory?

      3) What happens if you change the browser’s cache setting (Tools > Internet Options > Temporary Internet Files > Settings > Check for newer version of web pages = Every visit to the page)?

      4) Are you setting the content type header in the response that sends the PDF? Expiration? No-cache?

      Knowing this stuff helps narrow down the problem and getting the right solution.

      Thanks

    Viewing 3 reply threads
    Reply To: Force Browser Refresh

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: