Welcome Guest, Not a member yet? Register   Sign In
Image Caching
#1

[eluser]Twisted1919[/eluser]
Is there a way to cache all the images displayed in a web page using CodeIgniter ?
If there is , please point me to right direction , a library , anything ...
#2

[eluser]Eric Barnes[/eluser]
No I am not aware of any framework that will cache images. That is more a server setting and can be done with .htaccess in some cases:
http://www.webmasterworld.com/apache/3659750.htm
#3

[eluser]devbro[/eluser]
are the images created dynamically with CI? or do you have them stored in a folder?
in first case you can add headers that tell the browser how long keep the files for.
in second case there are .htaccess stuff that allow you to set these options.
#4

[eluser]Twisted1919[/eluser]
please tell me more , an example of how should i do Smile
my images are stored in folders , separate folder for each of my users and each folder has several photos.
LE :
This did the job :

Code:
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A86400
ExpiresByType image/x-icon A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A300
</IfModule>

# Set up caching on media files for 1 month
<FilesMatch "\.(ico|gif|jpg|jpeg|png|flv|pdf|swf|mov|mp3|wmv|ppt)$">
  ExpiresDefault A2419200
  Header append Cache-Control "public"
</FilesMatch>

# Set up 2 Hour caching on commonly updated files
<FilesMatch "\.(xml|txt|html|js|css)$">
  ExpiresDefault A7200
  Header append Cache-Control "private, must-revalidate"
</FilesMatch>

# Force no caching for dynamic files
<FilesMatch "\.(php|cgi|pl|htm)$">
  ExpiresDefault A0
  Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
  Header set Pragma "no-cache"
</FilesMatch>




Theme © iAndrew 2016 - Forum software by © MyBB