12 Replies Latest reply on Apr 22, 2017 6:53 AM by Alli Pierre Yotti

    Caching Blob Images in Browser

      Hey

      I have a application where More as 50 images are display in one of my Page. All Images are blob. The problem is that the Images are not caching. They reload each Time the Page reload. That is not efficient for the Users. How can I make it? it could very User friendly to have the Images Caching in Client Side.

       

       

      Thanks for Answers

      Pierre

        • 1. Re: Caching Blob Images in Browser
          fac586

          Alli Pierre Yotti wrote:

           

           

          I have a application where More as 50 images are display in one of my Page. All Images are blob. The problem is that the Images are not caching. They reload each Time the Page reload.

          How are the images downloaded?

          You are speak above about caching Images in Browsers.

          Who is speaking where? About what?

          • 2. Re: Caching Blob Images in Browser

            Hey fac586,

            Thanks to answers me.

            The images are dowloaded using file Browser. The Images are in the database as BLOB.

            In one Page i have over 50 Images. But it reload each time when the user submit the Pages.

             

            I want to cache it in Browser. I don't know how?

             

            "You are speak above about caching Images in Browsers."  it was error. I have remove it

             

             

            Regards

             

            Pierre

            • 3. Re: Caching Blob Images in Browser
              fac586

              Alli Pierre Yotti wrote:

               

              The images are dowloaded using file Browser. The Images are in the database as BLOB.

              In one Page i have over 50 Images. But it reload each time when the user submit the Pages.

              What mechanism is used in APEX to download the images?

              • 4. Re: Caching Blob Images in Browser

                hez,

                i have used Table APEX_APPLICATION_TEMP_FILES like at the below Picture

                 

                json.png

                 

                 

                 

                Regards

                 

                Pierre

                • 5. Re: Caching Blob Images in Browser
                  fac586

                  Alli Pierre Yotti wrote:

                   

                  i have used Table APEX_APPLICATION_TEMP_FILES like at the below Picture

                  That is how they are uploaded. How are they displayed/downloaded so as to appear as images in the browser?

                  • 6. Re: Caching Blob Images in Browser

                    Hey,

                     

                    That is the sql Query that i use.

                     

                    SELECT SAP_PRODUITS_ID,

                         decode(sap_prix,null,prix_rabai,sap_prix) card_subtext,

                         SAP_TITLE card_text,

                    GET_STARS(SAP_PRODUITS_ID,3) card_subtext1,

                    dbms_lob.getlength( ((select DATEIINHALT from TAB_DATEIEN where TAB_DATEIEN.SAP_PRODUITS_ID=SA_PRODUITS.SAP_PRODUITS_ID and position=1)))   card_title,

                    (select id from TAB_DATEIEN where TAB_DATEIEN.SAP_PRODUITS_ID=SA_PRODUITS.SAP_PRODUITS_ID and position=1) id,

                     

                     

                     

                        APEX_UTIL.PREPARE_URL('f?p=&APP_ID.:2:&SESSION.:DAS:&DEBUG.::P2_PRODUCT_ID:'||SAP_PRODUITS_ID) CARD_LINK

                     

                    FROM SA_PRODUITS

                    where (SAP_CATEGORIE=:P14_CATEGORIE and :P14_ID=1 )

                    or (SAP_SOUS_CATEGORIE=:P14_SUBCATEGORIE and SAP_CATEGORIE=:P14_CATEGORIE and :P14_ID=2)

                     

                     

                     

                     

                    order by case when upper(:P14_PRIX) = 'TITLE_ASC' then SAP_TITLE end ASC,

                             case when upper(:P14_PRIX) = 'TITLE_DESC' then SAP_TITLE end DESC,

                             case when upper(:P14_PRIX) = 'PRIX_ASC' then SAP_PRIX end ASC,

                             case when upper(:P14_PRIX) = 'PRIX_DESC' then SAP_PRIX end DESC

                     

                     

                    json.png

                     

                    dbms_lob.getlength( ((select DATEIINHALT from TAB_DATEIEN where TAB_DATEIEN.SAP_PRODUITS_ID=SA_PRODUITS.SAP_PRODUITS_ID and position=1)))   card_title,

                     

                    are the Images

                    1 person found this helpful
                    • 7. Re: Caching Blob Images in Browser
                      Mike Kutz

                      As I understand,  browsers to caching on their own.

                      The caching is done based on URL (and a flag in the HTTP Header)

                       

                      The question I have:

                      What is the size of the original image in Bytes?

                      What is the size of the original image in pixels? (Width  x height)

                       

                      Remember,:  the size="" attribute of the <img> tag is handled by the browser.  If you store a large image in the database and then shrink it to 80x80, the browser still has to download the original image ... and cache that one.

                       

                      My $0.02

                       

                      MK

                      • 8. Re: Caching Blob Images in Browser
                        fac586

                        Alli Pierre Yotti wrote:

                         

                        dbms_lob.getlength( ((select DATEIINHALT from TAB_DATEIEN where TAB_DATEIEN.SAP_PRODUITS_ID=SA_PRODUITS.SAP_PRODUITS_ID and position=1))) card_title,

                        Declarative BLOB masks generate URLs that download image files using the apex_util.get_blob_file API method. This does not set cache control headers. If you want to control browser caching using HTTP response headers, use a custom On-Demand Process to download the BLOB content.

                        1 person found this helpful
                        • 9. Re: Caching Blob Images in Browser

                          Hey,

                          Caching images on browser depend of his Size in Bytes and in Pixel? My Image are not Big

                          Regards

                           

                          Pierre

                          • 10. Re: Caching Blob Images in Browser

                            Hey,

                            after implemeted it ,

                            i have

                            <img src="f?p=115872:14:588785991432:APPLICATION_PROCESS=GETIMAGE:::FILE_ID:441">

                             

                            show as i inspected the Browser. But the image is not display and 441 is correct ID for a Image in the Database

                             

                            to make it i create a Process on demande

                             

                            begin

                                for c1 in (

                                    select *

                                    from TAB_DATEIEN

                                    where ID=:FILE_ID) loop

                                    --

                                    sys.htp.init;

                                    sys.owa_util.mime_header( c1.MIMETYPE, FALSE );

                                    sys.htp.p('Content-length: ' || sys.dbms_lob.getlength( c1.DATEIINHALT));//DATEIINHALT is the Blob

                                    sys.htp.p('Content-Disposition: attachment; filename="' || c1.DATEINAME || '"' );//DATEINAME name of File

                                    sys.htp.p('Cache-Control: max-age=3600');  -- tell the browser to cache for one hour, adjust as necessary

                                    sys.owa_util.http_header_close;

                                    sys.wpg_docload.download_file( c1.DATEIINHALT );

                                

                                    apex_application.stop_apex_engine;

                                end loop;

                            end;

                             

                            and i call the report like so

                             

                             

                             

                             

                            SELECT SAP_PRODUITS_ID,

                                 decode(sap_prix,null,prix_rabai,sap_prix) card_subtext,

                                 SAP_TITLE card_text,

                            GET_STARS(SAP_PRODUITS_ID,3) card_subtext1,

                              '<img src='||'f?p='||:APP_ID||':14:'||:APP_SESSION||':APPLICATION_PROCESS=GETIMAGE:::FILE_ID:'||SA_PRODUITS.SAP_PRODUITS_ID||'>' card_title,

                             

                             

                            (select id from TAB_DATEIEN where TAB_DATEIEN.SAP_PRODUITS_ID=SA_PRODUITS.SAP_PRODUITS_ID and position=1) id,

                             

                             

                             

                             

                             

                                APEX_UTIL.PREPARE_URL('f?p=&APP_ID.:2:&SESSION.:DAS:&DEBUG.::P2_PRODUCT_ID:'||SAP_PRODUITS_ID) CARD_LINK

                              

                            FROM SA_PRODUITS

                            where (SAP_CATEGORIE=:P14_CATEGORIE and :P14_ID=1 )

                            or (SAP_SOUS_CATEGORIE=:P14_SUBCATEGORIE and SAP_CATEGORIE=:P14_CATEGORIE and :P14_ID=2)

                             

                             

                             

                             

                            order by case when upper(:P14_PRIX) = 'TITLE_ASC' then SAP_TITLE end ASC,

                                     case when upper(:P14_PRIX) = 'TITLE_DESC' then SAP_TITLE end DESC,

                                     case when upper(:P14_PRIX) = 'PRIX_ASC' then SAP_PRIX end ASC,

                                     case when upper(:P14_PRIX) = 'PRIX_DESC' then SAP_PRIX end DESC

                            1 person found this helpful
                            • 11. Re: Caching Blob Images in Browser
                              fac586

                              Alli Pierre Yotti wrote:

                               

                              after implemeted it ,

                              i have

                              <img src="f?p=115872:14:588785991432:APPLICATION_PROCESS=GETIMAGE:::FILE_ID:441">

                               

                              show as i inspected the Browser. But the image is not display and 441 is correct ID for a Image in the Database

                               

                              to make it i create a Process on demande

                              Add support for debugging:

                               

                              begin
                                apex_debug.message('file_id = %s', :file_id);
                                for c1 in (
                                  select *
                                  from TAB_DATEIEN
                                  where ID=:FILE_ID)
                                loop
                                  --
                                  apex_debug.message('Downloading file: %s', c1.DATEINAME);
                                  sys.htp.init;
                                  sys.owa_util.mime_header( c1.MIMETYPE, FALSE );
                                  sys.htp.p('Content-length: ' || sys.dbms_lob.getlength( c1.DATEIINHALT));//DATEIINHALT is the Blob
                                  sys.htp.p('Content-Disposition: attachment; filename="' || c1.DATEINAME || '"' );//DATEINAME name of File
                                  sys.htp.p('Cache-Control: max-age=3600'); -- tell the browser to cache for one hour, adjust as necessary
                                  sys.owa_util.http_header_close;
                                  sys.wpg_docload.download_file( c1.DATEIINHALT );
                              
                                  apex_application.stop_apex_engine;
                                end loop;
                              end;
                              

                               

                              SELECT SAP_PRODUITS_ID,
                              decode(sap_prix,null,prix_rabai,sap_prix) card_subtext,
                              SAP_TITLE card_text,
                              GET_STARS(SAP_PRODUITS_ID,3) card_subtext1,
                              '<img src='||'f?p='||:APP_ID||':14:'||:APP_SESSION||':APPLICATION_PROCESS=GETIMAGE:'||:debug||'::FILE_ID:'||SA_PRODUITS.SAP_PRODUITS_ID||'>' card_title,
                              ...
                              

                               

                              Run the page in debug mode and check the debug logs for server errors or unexpected behaviour. Also use the browser developer tools to check the HTTP responses for the image requests.

                              • 12. Re: Caching Blob Images in Browser

                                Hey,

                                The Issue was the Authorization. I Set it to only "NON PUBLIC USER"

                                and i ran the Page public.

                                 

                                Thanks for help

                                Regards

                                 

                                Pierre