Set individual image cache/expire date












4















I have a question regarding the image caching and although I am not quite sure, if Magento SE is the right place for this kind of question, but I thought it would be interesting for others to know as well. (If you disagree, I would be glad to know what stack exchange would be a better place for it :-) )



In my shop I am using an image that was usually delivered from another server. It is a seal that can change its content about 1-2 times per day.
Unfortunately the other server is not very fast, so I wrote a caching module for it. The module has a cron observer that loads the image once per day and stores it in the media directory.
This is ready and working as expected.



My problem is, that the browser does not show the current version of the image.
As far as I can tell, Magento sets the image expiration per default as "access plus 1 month" in the .htaccess file in the Magento root directory.
This is ok for all images except the one I mentioned.



What is the best way to tell the webserver that this single image has an expiration time of 12 or 24 hours?
I would be fine with a solution, that explicitly uses the filename of my image.










share|improve this question





























    4















    I have a question regarding the image caching and although I am not quite sure, if Magento SE is the right place for this kind of question, but I thought it would be interesting for others to know as well. (If you disagree, I would be glad to know what stack exchange would be a better place for it :-) )



    In my shop I am using an image that was usually delivered from another server. It is a seal that can change its content about 1-2 times per day.
    Unfortunately the other server is not very fast, so I wrote a caching module for it. The module has a cron observer that loads the image once per day and stores it in the media directory.
    This is ready and working as expected.



    My problem is, that the browser does not show the current version of the image.
    As far as I can tell, Magento sets the image expiration per default as "access plus 1 month" in the .htaccess file in the Magento root directory.
    This is ok for all images except the one I mentioned.



    What is the best way to tell the webserver that this single image has an expiration time of 12 or 24 hours?
    I would be fine with a solution, that explicitly uses the filename of my image.










    share|improve this question



























      4












      4








      4


      1






      I have a question regarding the image caching and although I am not quite sure, if Magento SE is the right place for this kind of question, but I thought it would be interesting for others to know as well. (If you disagree, I would be glad to know what stack exchange would be a better place for it :-) )



      In my shop I am using an image that was usually delivered from another server. It is a seal that can change its content about 1-2 times per day.
      Unfortunately the other server is not very fast, so I wrote a caching module for it. The module has a cron observer that loads the image once per day and stores it in the media directory.
      This is ready and working as expected.



      My problem is, that the browser does not show the current version of the image.
      As far as I can tell, Magento sets the image expiration per default as "access plus 1 month" in the .htaccess file in the Magento root directory.
      This is ok for all images except the one I mentioned.



      What is the best way to tell the webserver that this single image has an expiration time of 12 or 24 hours?
      I would be fine with a solution, that explicitly uses the filename of my image.










      share|improve this question
















      I have a question regarding the image caching and although I am not quite sure, if Magento SE is the right place for this kind of question, but I thought it would be interesting for others to know as well. (If you disagree, I would be glad to know what stack exchange would be a better place for it :-) )



      In my shop I am using an image that was usually delivered from another server. It is a seal that can change its content about 1-2 times per day.
      Unfortunately the other server is not very fast, so I wrote a caching module for it. The module has a cron observer that loads the image once per day and stores it in the media directory.
      This is ready and working as expected.



      My problem is, that the browser does not show the current version of the image.
      As far as I can tell, Magento sets the image expiration per default as "access plus 1 month" in the .htaccess file in the Magento root directory.
      This is ok for all images except the one I mentioned.



      What is the best way to tell the webserver that this single image has an expiration time of 12 or 24 hours?
      I would be fine with a solution, that explicitly uses the filename of my image.







      htaccess






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '17 at 13:40









      Teja Bhagavan Kollepara

      2,94841847




      2,94841847










      asked Nov 18 '13 at 16:57









      CelldwellerCelldweller

      61821325




      61821325






















          3 Answers
          3






          active

          oldest

          votes


















          3














          The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images



          This seems like the most logical solution. So, you'd end up with something like :



          <FilesMatch "^(seal.jpg)$">
          ExpiresActive on
          ExpiresDefault "access plus 1 month"
          </FilesMatch>


          You should be able to use any of the following for timings:




          • years

          • months

          • weeks

          • days

          • hours

          • minutes

          • seconds






          share|improve this answer

































            1














            #THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
            #THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
            #PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
            #IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
            #APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
            #THE SEAL.JPG FILE IS.
            #IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
            #USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
            <IfModule mod_expires.c>
            ExpiresActive On
            ExpiresByType image/jpeg "access plus 1 month"
            <FilesMatch "^seal.jpg$">
            ExpiresByType image/jpeg "access plus 12 hours"
            </FilesMatch>
            <FilesMatch "^seal.*.jpg$">
            ExpiresByType image/jpeg "access plus 12 hours"
            </FilesMatch>
            </IfModule>

            **I am 99% certain it does not matter which comes first
            **(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
            **FilesMatch will take precedence.
            **@Douglas answer set me on the right track,**
            **but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
            **What did i get wrong?**
            #keywords: how to set Expires HTTP headers on a file named X.
            #change the cache of one file. cache only one file. how to cache one file.
            #I do not want to cache by type Web server cache one file





            share|improve this answer

































              0














              Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:



              ## EXPIRES CACHING  ##
              <IfModule mod_expires.c>
              ExpiresActive on
              ExpiresByType image/jpg "access 1 year"
              ExpiresByType image/jpeg "access 1 year"
              ExpiresByType image/gif "access 1 year"
              ExpiresByType image/png "access 1 year"
              ExpiresByType text/css "access 1 month"
              ExpiresByType text/x-javascript "access 1 month"
              ExpiresByType application/x-javascript "access 1 month"
              ExpiresByType application/pdf "access 1 month"
              ExpiresByType application/x-shockwave-flash "access 1 month"
              ExpiresByType image/x-icon "access 1 year"
              ExpiresDefault "access 2 days"
              </IfModule>
              ## EXPIRES CACHING ##


              Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?






              share|improve this answer
























              • That is the code from the .htaccess but I would like to know who I can address a specific image. e.g. I have an image seal.jpg. What would I need to write in the .htaccess file in order to have a file expiration of 1 day? I doubt it is something like ExpiresByName seal.jpg

                – Celldweller
                Nov 19 '13 at 15:57













              • Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…

                – MagentoMac
                Nov 19 '13 at 21:50











              • Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html

                – MagentoMac
                Nov 19 '13 at 21:51











              • Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?

                – Celldweller
                Nov 20 '13 at 7:33











              • I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>

                – MagentoMac
                Nov 20 '13 at 18:41











              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "479"
              };
              initTagRenderer("".split(" "), "".split(" "), channelOptions);

              StackExchange.using("externalEditor", function() {
              // Have to fire editor after snippets, if snippets enabled
              if (StackExchange.settings.snippets.snippetsEnabled) {
              StackExchange.using("snippets", function() {
              createEditor();
              });
              }
              else {
              createEditor();
              }
              });

              function createEditor() {
              StackExchange.prepareEditor({
              heartbeatType: 'answer',
              autoActivateHeartbeat: false,
              convertImagesToLinks: false,
              noModals: true,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              imageUploader: {
              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
              allowUrls: true
              },
              onDemand: true,
              discardSelector: ".discard-answer"
              ,immediatelyShowMarkdownHelp:true
              });


              }
              });














              draft saved

              draft discarded


















              StackExchange.ready(
              function () {
              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f10915%2fset-individual-image-cache-expire-date%23new-answer', 'question_page');
              }
              );

              Post as a guest















              Required, but never shown

























              3 Answers
              3






              active

              oldest

              votes








              3 Answers
              3






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes









              3














              The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images



              This seems like the most logical solution. So, you'd end up with something like :



              <FilesMatch "^(seal.jpg)$">
              ExpiresActive on
              ExpiresDefault "access plus 1 month"
              </FilesMatch>


              You should be able to use any of the following for timings:




              • years

              • months

              • weeks

              • days

              • hours

              • minutes

              • seconds






              share|improve this answer






























                3














                The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images



                This seems like the most logical solution. So, you'd end up with something like :



                <FilesMatch "^(seal.jpg)$">
                ExpiresActive on
                ExpiresDefault "access plus 1 month"
                </FilesMatch>


                You should be able to use any of the following for timings:




                • years

                • months

                • weeks

                • days

                • hours

                • minutes

                • seconds






                share|improve this answer




























                  3












                  3








                  3







                  The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images



                  This seems like the most logical solution. So, you'd end up with something like :



                  <FilesMatch "^(seal.jpg)$">
                  ExpiresActive on
                  ExpiresDefault "access plus 1 month"
                  </FilesMatch>


                  You should be able to use any of the following for timings:




                  • years

                  • months

                  • weeks

                  • days

                  • hours

                  • minutes

                  • seconds






                  share|improve this answer















                  The following article makes use of the FilesMatch directive for .htaccess - https://stackoverflow.com/questions/2508783/add-expires-headers-for-specific-images



                  This seems like the most logical solution. So, you'd end up with something like :



                  <FilesMatch "^(seal.jpg)$">
                  ExpiresActive on
                  ExpiresDefault "access plus 1 month"
                  </FilesMatch>


                  You should be able to use any of the following for timings:




                  • years

                  • months

                  • weeks

                  • days

                  • hours

                  • minutes

                  • seconds







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited May 23 '17 at 12:37









                  Community

                  1




                  1










                  answered Mar 19 '14 at 13:40









                  Douglas RadburnDouglas Radburn

                  1,880927




                  1,880927

























                      1














                      #THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
                      #THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
                      #PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
                      #IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
                      #APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
                      #THE SEAL.JPG FILE IS.
                      #IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
                      #USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
                      <IfModule mod_expires.c>
                      ExpiresActive On
                      ExpiresByType image/jpeg "access plus 1 month"
                      <FilesMatch "^seal.jpg$">
                      ExpiresByType image/jpeg "access plus 12 hours"
                      </FilesMatch>
                      <FilesMatch "^seal.*.jpg$">
                      ExpiresByType image/jpeg "access plus 12 hours"
                      </FilesMatch>
                      </IfModule>

                      **I am 99% certain it does not matter which comes first
                      **(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
                      **FilesMatch will take precedence.
                      **@Douglas answer set me on the right track,**
                      **but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
                      **What did i get wrong?**
                      #keywords: how to set Expires HTTP headers on a file named X.
                      #change the cache of one file. cache only one file. how to cache one file.
                      #I do not want to cache by type Web server cache one file





                      share|improve this answer






























                        1














                        #THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
                        #THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
                        #PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
                        #IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
                        #APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
                        #THE SEAL.JPG FILE IS.
                        #IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
                        #USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
                        <IfModule mod_expires.c>
                        ExpiresActive On
                        ExpiresByType image/jpeg "access plus 1 month"
                        <FilesMatch "^seal.jpg$">
                        ExpiresByType image/jpeg "access plus 12 hours"
                        </FilesMatch>
                        <FilesMatch "^seal.*.jpg$">
                        ExpiresByType image/jpeg "access plus 12 hours"
                        </FilesMatch>
                        </IfModule>

                        **I am 99% certain it does not matter which comes first
                        **(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
                        **FilesMatch will take precedence.
                        **@Douglas answer set me on the right track,**
                        **but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
                        **What did i get wrong?**
                        #keywords: how to set Expires HTTP headers on a file named X.
                        #change the cache of one file. cache only one file. how to cache one file.
                        #I do not want to cache by type Web server cache one file





                        share|improve this answer




























                          1












                          1








                          1







                          #THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
                          #THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
                          #PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
                          #IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
                          #APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
                          #THE SEAL.JPG FILE IS.
                          #IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
                          #USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
                          <IfModule mod_expires.c>
                          ExpiresActive On
                          ExpiresByType image/jpeg "access plus 1 month"
                          <FilesMatch "^seal.jpg$">
                          ExpiresByType image/jpeg "access plus 12 hours"
                          </FilesMatch>
                          <FilesMatch "^seal.*.jpg$">
                          ExpiresByType image/jpeg "access plus 12 hours"
                          </FilesMatch>
                          </IfModule>

                          **I am 99% certain it does not matter which comes first
                          **(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
                          **FilesMatch will take precedence.
                          **@Douglas answer set me on the right track,**
                          **but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
                          **What did i get wrong?**
                          #keywords: how to set Expires HTTP headers on a file named X.
                          #change the cache of one file. cache only one file. how to cache one file.
                          #I do not want to cache by type Web server cache one file





                          share|improve this answer















                          #THIS IS WRITTEN TO WORK IN YOUR .HTACCESS FILE
                          #THIS IS WHAT I GOT TO WORK ON APACHE 2.2 ON 111317 ON A SHARED SERVER AT GODADDY.COM
                          #PLACED IN YOUR ROOT .HTACCESS THIS APPLYS TO EVERY FILE NAMED SEAL.JPG
                          #IF YOU HAVE MANY SEAL.JPG AND YOU WANT IT TO
                          #APPLY TO JUST ONE PUT THIS IN THE .HTACCESS FILE IN THE DIRECTORY WHERE
                          #THE SEAL.JPG FILE IS.
                          #IF YOU PUT A TIMESTAMP IN THE FILENAME (I.E. sealTIMESTAMP.jpg )
                          #USE <FilesMatch "^seal.*.jpg$". THE TWO DOTS ARE CORRECT.
                          <IfModule mod_expires.c>
                          ExpiresActive On
                          ExpiresByType image/jpeg "access plus 1 month"
                          <FilesMatch "^seal.jpg$">
                          ExpiresByType image/jpeg "access plus 12 hours"
                          </FilesMatch>
                          <FilesMatch "^seal.*.jpg$">
                          ExpiresByType image/jpeg "access plus 12 hours"
                          </FilesMatch>
                          </IfModule>

                          **I am 99% certain it does not matter which comes first
                          **(ExpiresByType image/jpeg "access plus 1 month") or (<FilesMatch "^seal.jpg$">)
                          **FilesMatch will take precedence.
                          **@Douglas answer set me on the right track,**
                          **but I could not get his <FilesMatch "^(seal.jpg)$"> to work.**
                          **What did i get wrong?**
                          #keywords: how to set Expires HTTP headers on a file named X.
                          #change the cache of one file. cache only one file. how to cache one file.
                          #I do not want to cache by type Web server cache one file






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited 1 hour ago

























                          answered Oct 24 '17 at 2:18









                          somebadhatsomebadhat

                          114




                          114























                              0














                              Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:



                              ## EXPIRES CACHING  ##
                              <IfModule mod_expires.c>
                              ExpiresActive on
                              ExpiresByType image/jpg "access 1 year"
                              ExpiresByType image/jpeg "access 1 year"
                              ExpiresByType image/gif "access 1 year"
                              ExpiresByType image/png "access 1 year"
                              ExpiresByType text/css "access 1 month"
                              ExpiresByType text/x-javascript "access 1 month"
                              ExpiresByType application/x-javascript "access 1 month"
                              ExpiresByType application/pdf "access 1 month"
                              ExpiresByType application/x-shockwave-flash "access 1 month"
                              ExpiresByType image/x-icon "access 1 year"
                              ExpiresDefault "access 2 days"
                              </IfModule>
                              ## EXPIRES CACHING ##


                              Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?






                              share|improve this answer
























                              • That is the code from the .htaccess but I would like to know who I can address a specific image. e.g. I have an image seal.jpg. What would I need to write in the .htaccess file in order to have a file expiration of 1 day? I doubt it is something like ExpiresByName seal.jpg

                                – Celldweller
                                Nov 19 '13 at 15:57













                              • Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…

                                – MagentoMac
                                Nov 19 '13 at 21:50











                              • Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html

                                – MagentoMac
                                Nov 19 '13 at 21:51











                              • Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?

                                – Celldweller
                                Nov 20 '13 at 7:33











                              • I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>

                                – MagentoMac
                                Nov 20 '13 at 18:41
















                              0














                              Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:



                              ## EXPIRES CACHING  ##
                              <IfModule mod_expires.c>
                              ExpiresActive on
                              ExpiresByType image/jpg "access 1 year"
                              ExpiresByType image/jpeg "access 1 year"
                              ExpiresByType image/gif "access 1 year"
                              ExpiresByType image/png "access 1 year"
                              ExpiresByType text/css "access 1 month"
                              ExpiresByType text/x-javascript "access 1 month"
                              ExpiresByType application/x-javascript "access 1 month"
                              ExpiresByType application/pdf "access 1 month"
                              ExpiresByType application/x-shockwave-flash "access 1 month"
                              ExpiresByType image/x-icon "access 1 year"
                              ExpiresDefault "access 2 days"
                              </IfModule>
                              ## EXPIRES CACHING ##


                              Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?






                              share|improve this answer
























                              • That is the code from the .htaccess but I would like to know who I can address a specific image. e.g. I have an image seal.jpg. What would I need to write in the .htaccess file in order to have a file expiration of 1 day? I doubt it is something like ExpiresByName seal.jpg

                                – Celldweller
                                Nov 19 '13 at 15:57













                              • Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…

                                – MagentoMac
                                Nov 19 '13 at 21:50











                              • Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html

                                – MagentoMac
                                Nov 19 '13 at 21:51











                              • Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?

                                – Celldweller
                                Nov 20 '13 at 7:33











                              • I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>

                                – MagentoMac
                                Nov 20 '13 at 18:41














                              0












                              0








                              0







                              Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:



                              ## EXPIRES CACHING  ##
                              <IfModule mod_expires.c>
                              ExpiresActive on
                              ExpiresByType image/jpg "access 1 year"
                              ExpiresByType image/jpeg "access 1 year"
                              ExpiresByType image/gif "access 1 year"
                              ExpiresByType image/png "access 1 year"
                              ExpiresByType text/css "access 1 month"
                              ExpiresByType text/x-javascript "access 1 month"
                              ExpiresByType application/x-javascript "access 1 month"
                              ExpiresByType application/pdf "access 1 month"
                              ExpiresByType application/x-shockwave-flash "access 1 month"
                              ExpiresByType image/x-icon "access 1 year"
                              ExpiresDefault "access 2 days"
                              </IfModule>
                              ## EXPIRES CACHING ##


                              Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?






                              share|improve this answer













                              Not sure on the exact code for less than 1 day, but it would be something along the lines of the below in full that you would need inside your .htaccess file in root:



                              ## EXPIRES CACHING  ##
                              <IfModule mod_expires.c>
                              ExpiresActive on
                              ExpiresByType image/jpg "access 1 year"
                              ExpiresByType image/jpeg "access 1 year"
                              ExpiresByType image/gif "access 1 year"
                              ExpiresByType image/png "access 1 year"
                              ExpiresByType text/css "access 1 month"
                              ExpiresByType text/x-javascript "access 1 month"
                              ExpiresByType application/x-javascript "access 1 month"
                              ExpiresByType application/pdf "access 1 month"
                              ExpiresByType application/x-shockwave-flash "access 1 month"
                              ExpiresByType image/x-icon "access 1 year"
                              ExpiresDefault "access 2 days"
                              </IfModule>
                              ## EXPIRES CACHING ##


                              Guessing it is probably simply "access 12 hours" ? or "access 1 day" ?







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 18 '13 at 23:04









                              MagentoMacMagentoMac

                              62441333




                              62441333













                              • That is the code from the .htaccess but I would like to know who I can address a specific image. e.g. I have an image seal.jpg. What would I need to write in the .htaccess file in order to have a file expiration of 1 day? I doubt it is something like ExpiresByName seal.jpg

                                – Celldweller
                                Nov 19 '13 at 15:57













                              • Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…

                                – MagentoMac
                                Nov 19 '13 at 21:50











                              • Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html

                                – MagentoMac
                                Nov 19 '13 at 21:51











                              • Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?

                                – Celldweller
                                Nov 20 '13 at 7:33











                              • I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>

                                – MagentoMac
                                Nov 20 '13 at 18:41



















                              • That is the code from the .htaccess but I would like to know who I can address a specific image. e.g. I have an image seal.jpg. What would I need to write in the .htaccess file in order to have a file expiration of 1 day? I doubt it is something like ExpiresByName seal.jpg

                                – Celldweller
                                Nov 19 '13 at 15:57













                              • Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…

                                – MagentoMac
                                Nov 19 '13 at 21:50











                              • Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html

                                – MagentoMac
                                Nov 19 '13 at 21:51











                              • Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?

                                – Celldweller
                                Nov 20 '13 at 7:33











                              • I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>

                                – MagentoMac
                                Nov 20 '13 at 18:41

















                              That is the code from the .htaccess but I would like to know who I can address a specific image. e.g. I have an image seal.jpg. What would I need to write in the .htaccess file in order to have a file expiration of 1 day? I doubt it is something like ExpiresByName seal.jpg

                              – Celldweller
                              Nov 19 '13 at 15:57







                              That is the code from the .htaccess but I would like to know who I can address a specific image. e.g. I have an image seal.jpg. What would I need to write in the .htaccess file in order to have a file expiration of 1 day? I doubt it is something like ExpiresByName seal.jpg

                              – Celldweller
                              Nov 19 '13 at 15:57















                              Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…

                              – MagentoMac
                              Nov 19 '13 at 21:50





                              Sorry, I don't understand your question. I think it's just that your wording is muddled up a bit. The below link seems to be most extensive around showing the possible options you can add in: stackoverflow.com/questions/5531994/…

                              – MagentoMac
                              Nov 19 '13 at 21:50













                              Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html

                              – MagentoMac
                              Nov 19 '13 at 21:51





                              Or the below is just a more general page on the mod_expires apache module which would be worth reading through in full to: httpd.apache.org/docs/current/mod/mod_expires.html

                              – MagentoMac
                              Nov 19 '13 at 21:51













                              Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?

                              – Celldweller
                              Nov 20 '13 at 7:33





                              Sorry to confuse you. My intention is to have a custom expiration date for one single specific image. Not by type like gif,jpg or png, but a single image. It is like: "The expiration date for all image is 1 month, but for the image seal.jpg it is 1 day". Hope I could clarify things up?

                              – Celldweller
                              Nov 20 '13 at 7:33













                              I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>

                              – MagentoMac
                              Nov 20 '13 at 18:41





                              I'm with you now. I've never seen such a request. This might not be 100% accurate as I don't have the means to test for you, but it would be something along the below: Alias /IMAGENAME.jpg "/var/www/html/images/IMAGENAME.jpg" <Directory "/var/www/html"> <Files IMAGENAME.jpg> ExpiresActive On ExpiresDefault "access plus 1 month" </Files> </Directory>

                              – MagentoMac
                              Nov 20 '13 at 18:41


















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Magento Stack Exchange!


                              • Please be sure to answer the question. Provide details and share your research!

                              But avoid



                              • Asking for help, clarification, or responding to other answers.

                              • Making statements based on opinion; back them up with references or personal experience.


                              To learn more, see our tips on writing great answers.




                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function () {
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f10915%2fset-individual-image-cache-expire-date%23new-answer', 'question_page');
                              }
                              );

                              Post as a guest















                              Required, but never shown





















































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown

































                              Required, but never shown














                              Required, but never shown












                              Required, but never shown







                              Required, but never shown







                              Popular posts from this blog

                              Magento 2 controller redirect on button click in phtml file

                              Polycentropodidae