Is there a difference between preloading images vs cacheing images?

Isn't the purpose of preloading images to cache them so that page is easier to load?

## 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/html "access 1 month"
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## EXPIRES CACHING ##

## GZIP ##
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml text/css application/x-javascript application/javascript
## GZIP ##

I was looking into preloading images with javascript but then I realized, wait a minute, I already do that with a few lines in my .htaccess file. If I have the latter, why would I need the jscript?

Answers 1

  • Your .htaccess rules don't preload/precache the images. All they do is tell the browser that if it loads an image, that's how long it should cache it for.

    Preloading images is used to ensure that the image has been downloaded, even the first time, before you go to show it. (At which point, your .htaccess rules will tell the browser how long it can keep it around, if it wants to.)


Related Articles