No-cache forum?

  • alex89
  • Bronze Member
  • Bronze Member
  • User avatar
  • Posts: 239
  • Loc: Western Australia

Post 3+ Months Ago

I've got a forum (similar to Ozzu), with a fair few (bandwidth-unfriendly) scripts & images.

Do I need the <meta http-equiv="pragma" CONTENT="no-cache" /> tag?

Is it possible to tell the browser that I'd like to cache the scripts & images, and refresh the html? (To see the most recent posts etc)
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Posts: 481

Post 3+ Months Ago

I think the browser will anyway cache scripts and images separately. Cache control is determined individually for each file as per the HTTP header. The META tag is just a substitute for the HTTP header for webpages alone.
  • alex89
  • Bronze Member
  • Bronze Member
  • User avatar
  • Posts: 239
  • Loc: Western Australia

Post 3+ Months Ago

Ah thankyou, so I don't need it?
  • casablanca
  • Proficient
  • Proficient
  • User avatar
  • Posts: 481

Post 3+ Months Ago

Probably not. Most modern browsers cache all objects anyway, but compare the last modified time with the server to make sure cached objects are up to date. In my experience, I really haven't had problems with the browser automatically refreshing dynamic pages.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9099
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

Here is an example of how Ozzu controls caching and compression using an .htaccess file on Apache:

Code: [ Select ]
# Cache certain files by type for 30 days
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/png A2592000
ExpiresByType application/x-shockwave-flash A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000

# Compress certain file types by extension:
<FilesMatch "\.(html|css|js)$">
SetOutputFilter DEFLATE
</FilesMatch>
  1. # Cache certain files by type for 30 days
  2. ExpiresActive On
  3. ExpiresByType image/gif A2592000
  4. ExpiresByType image/jpeg A2592000
  5. ExpiresByType image/png A2592000
  6. ExpiresByType application/x-shockwave-flash A2592000
  7. ExpiresByType text/css A2592000
  8. ExpiresByType text/javascript A2592000
  9. # Compress certain file types by extension:
  10. <FilesMatch "\.(html|css|js)$">
  11. SetOutputFilter DEFLATE
  12. </FilesMatch>


This basically makes so gif, jpg, png, flash, css, and javascript are cached for 2592000 seconds (30 days). Also .html, .css, and .js files are compressed so that the file sizes are much smaller to transfer reducing the amount of bandwidth needed and speeding up load time for the site. Do not compress files such as images as they are most likely already compressed and re-compressing them will only make file sizes larger and less optimized.

Also if you use phpBB there is an option in the admin area so that you can send all forum pages using compression so that bandwidth transfer is lower. You can find that under the General Tab, then Server Settings, then enable Gzip Compression. The description for that says:

Quote:
Generated content will be compressed prior to sending it to the user. This can reduce network traffic but will also increase CPU usage on both server and client side.


Hope that helps :)
  • alex89
  • Bronze Member
  • Bronze Member
  • User avatar
  • Posts: 239
  • Loc: Western Australia

Post 3+ Months Ago

Thanks Brian, casablanca

Since mine is a PERL forum, should I add .pl to the compressed regex as well?

I've got the following code for my htaccess now:

Code: [ Select ]
RewriteEngine On
# Forward www to without
RewriteCond %{HTTP_HOST} !^uwadb\.com$
RewriteRule (.*) http://uwadb.com/$1 [R=301,L]

# Use PHP5 as default
AddHandler application/x-httpd-php5 .php

# Cache certain files by type for 30 days
ExpiresActive On
ExpiresByType image/gif A2592000
ExpiresByType image/jpeg A2592000
ExpiresByType image/png A2592000
ExpiresByType application/x-shockwave-flash A2592000
ExpiresByType text/css A2592000
ExpiresByType text/javascript A2592000

# Compress certain file types by extension
<IfModule mod_deflate.c>
<FilesMatch "\.(html|js|css|pl)$">
SetOutputFilter DEFLATE
</FilesMatch>
</IfModule>
  1. RewriteEngine On
  2. # Forward www to without
  3. RewriteCond %{HTTP_HOST} !^uwadb\.com$
  4. RewriteRule (.*) http://uwadb.com/$1 [R=301,L]
  5. # Use PHP5 as default
  6. AddHandler application/x-httpd-php5 .php
  7. # Cache certain files by type for 30 days
  8. ExpiresActive On
  9. ExpiresByType image/gif A2592000
  10. ExpiresByType image/jpeg A2592000
  11. ExpiresByType image/png A2592000
  12. ExpiresByType application/x-shockwave-flash A2592000
  13. ExpiresByType text/css A2592000
  14. ExpiresByType text/javascript A2592000
  15. # Compress certain file types by extension
  16. <IfModule mod_deflate.c>
  17. <FilesMatch "\.(html|js|css|pl)$">
  18. SetOutputFilter DEFLATE
  19. </FilesMatch>
  20. </IfModule>


And I've removed the html line. Thanks guys :)

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 46 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.