Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Aliasing images to a remote server with .htaccess

Status
Not open for further replies.

monkey64

Technical User
Apr 27, 2008
69
0
0
GB
I have been trialing Amazon's S3 service with the intention of using it to serve images from instead of choking the current web server with multiple image requests. Early tests were encouraging, so I started to think about how I could serve the files on the Amazon S3 storage service.

The following code in my .htaccess does the job, but for some reason, the page takes ages to load. I can't help thinking the code below is not that efficient.

RewriteRule images/(.*)$
Could someone enlighten me?
Thanks
 
you could add [L] to the end of that rule to tell the rewrite engine to stop processing any more rules

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
Chris

Tried adding the [L] after the rule, but I still see the same performance hit.

To prove that my rule was causing the issue, I created a series of test pages. One had the hardcoded absolute image URLs and this page was on average 10 times faster to load than when using the .htaccess rewrite rule.

Guess I will have to ammend my image URL's...
 
Just a thought- this method requires 2 web hits to get an image.

1. (browser is instructed to go elsewhere)
2.
The first hit should be pretty quick (you can check with tools like Tamperdata or Yslow), but it's still another connection. With the actual image url in the page, only the second query is made.

Also, the default return code is 302. Using R=301 might help a little if the same image is used multiple times in the page.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top