php - How to load new images, when changed in a web application -


How to push new images into a web application, so that the cache can not be taken? When I'm getting a new JS or CSS file, it's easy. Because they are in smart templates, and I have a version number (like a.js? V = 9) in the URL.

Now, there are problems with images: -

They are referred to as CSS files, and I can not have a version variable.

So, how do you do it?

In the middle of the most clean and easy way, I would:

  • In CSS, point to images with URLs with specific markers; Such as " image.png? VERSION_NUMBER " (literaly)
    • This will help to develop the CSS file
    • To avoid any problems with the cache, I will use some kind of "build process", which will mark it as VERSION_NUMBER in each CSS file (and possibly, JS, PHP , HTML, ...)
      • This will create modified files with the correct version number
      • those files will be deployed to the webserver
      • Respect The term as, VERSION_NUMBER may SVN revision of each file; In this way, only the modified files must be modified; But also difficult: for each file (for each url in css file!), You have to set the modification number before changing the marker!

    If some browsers do not cache images / JS / CSS due to string, the marker can be included in file names.

    And now you have "build process", you can also use it for example to reduce JS and CSS files like some other manipulations

    on one side As a note: Yes, the construction process and test preparation takes some time; This server can be easy via PHP for CSS files, using a variable in them to indicate the version number ... but, to serve CSS files (at least one per page PHP; maybe More!) She would not be wise; Therefore, it would be better to take a little longer to write build process ...


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -