Jump to content
MakeWebGames

Recommended Posts

Posted

I ran across this on my travels and it works like a charm! I can see a massive increase in my page loading speed.

Add this to your .htaccess file.

# Cache static content for 1 MONTH

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|swf|mp3|mp4|css|js|txt|xml)$">

Header set Cache-Control "public"

Header set Cache-Control "max-age=2592000, public"

Header unset Last-Modified

</FilesMatch>

# Remove ETag headers

Header unset ETag

FileETag None

# compress text, html, javascript, css, xml:

AddOutputFilterByType DEFLATE text/plain

AddOutputFilterByType DEFLATE text/html

AddOutputFilterByType DEFLATE text/xml

AddOutputFilterByType DEFLATE text/css

AddOutputFilterByType DEFLATE application/xml

AddOutputFilterByType DEFLATE application/xhtml+xml

AddOutputFilterByType DEFLATE application/rss+xml

AddOutputFilterByType DEFLATE application/javascript

AddOutputFilterByType DEFLATE application/x-javascript

Posted

Anyone got any thing to say about this ?....its not something im familiar with.

I would like to use it if it works as you say :)

Any downside to it ?

Posted

The first part of it, as it states, seems to cache images and other static material for a month as indicated by the max-age, so this means static content doesn't need to be reloaded everytime?

The other part looks like it compresses content. I'm just guessing at what the processes are.

Posted

lol...yea i read the comments aswell...

Seems like something nice to add....

would like to know about any downsides before I try it out though..

Posted

A potential downside is that if you have an image but then update this image and keep the same filename, it may not be updated for the user if they visited the page within the last month.

Posted
lol...yea i read the comments aswell...

Seems like something nice to add....

would like to know about any downsides before I try it out though..

It is nice to add believe me. It made my game 100 times faster than it was. The only downside was mentioned by US Vice. If you have all your graphics in place and don't intend to change them like me then you are fine. You could always change the file name of the graphics file if you do decide to update a graphic.

Posted

Ah i see, I actually added it to my site and I do see a nice speed increase.

Would refreshing not show the new images ?...I do have some image updates still to be made.

if not i could simply lower the monthly timer temporarily :)

Nice addition Mystical :D

UPDATE:

Refreshing will show the new image :)

It did for me anyway just now....lol

Posted
I have tested this out as well, I must say I do see a difference. Very nice catch there mystical. Though may I ask where you got it from?

I just did a search on how to improve a web sites speed with .htaccess and found the link here :

http://forums.hostgator.com/speed-up-your-site-htaccess-t132870.html?amp

I found it a while ago but kept forgetting to post it here for everyone. It does work pretty well! My site was slower than molasses until I added that code. Gotta love the internet and smart people!

Posted

This is a very commonly known caching method. I would suggest anyone with a production site to be using some form of caching, during development it's not really needed due to how much you're changing the pages and other various elements and you don't want to be having to clear your cache every few seconds.

In essence it's just forcing your browser to use the images already in your cache before checking if their are news ones of the server. This means the site is basically being loaded from your computer and the page content is being filled in by the server.

Don't quote me on that, it's how I understand caching.

Posted
Ah i see, I actually added it to my site and I do see a nice speed increase.

Would refreshing not show the new images ?...I do have some image updates still to be made.

if not i could simply lower the monthly timer temporarily :)

Nice addition Mystical :D

If your using something like this is a good idea to include a version or date in the image name. Helps avoid problems when updating the image :)

  • 2 weeks later...
Posted

@Curt, yes you can lower the timer.

You can also specify different rules for different content types. In Mystical's script, it categorizes all files under one rule. But perhaps you will be updating images or CSS files more than once per month. If that is the case, you could make a separate rule just for them and have a different timer. You could potentially have different rules for each file type if you'd like.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...