开发者

How to cache scripts and images from my site?

开发者 https://www.devze.com 2023-02-28 03:42 出处:网络
Question :::::: I have been trying to create a site (Hosted on x10hosting). So I have been searching how to build a fast site. And I got a page to improve Jquery codes. Below is the link to the p

Question ::::::


I have been trying to create a site (Hosted on x10hosting). So I have been searching how to build a fast site. And I got a page to improve Jquery codes. Below is the link to the page. In that page I read that including Jquery framework codes from Google开发者_开发百科.com can speed up the site. And I also find out the cause to it, as the Google.com caches the Jquery framework code so that user doesn't have to download the Jquery framework code again and again. So I was thinking that can I do that too with my site. Well I'm using Linux based site. So can anyone suggest a page or a code to cache scripts or images in my site so that user doesn't have to download it again and again.


Links::::::


Improve JQuery


THANKS IN ADVANCE!


Chances are that as long as you use normal, static files (ending in .js, .gif and so on), your server already does caching for you.

You can find out using a tool like Firebug in Firefox, or the built-in developer console in Chrome. The easiest way to get there is by right-clicking an element, and choosing "Inspect element".

If you switch to the "Net" tab, you will see all the requests that had to be made for the current file.

How to cache scripts and images from my site?

304 not modified and (from cache) means that the resource was not loaded again. If you see those for static resources, there is some caching already in place. The main document usually gets reloaded every time; the same goes for tracking codes like Google Analytics, and Ads. On a big site, you will expect to see a number of 200 OK requests as well.

In the tab, you can also find out the response headers of each resource. This tutorial could help deciphering what each header means: Caching Tutorial for web authors and webmasters

Fine-tuning caching is a very complex field. Here is a question that deals with caching images on Apache. Stack Overflow has a variety of existing questions on this.

If you want to generally look into speeding up your site, check out this question: Optimizations to reduce website loading time


As pekka said fine tuning caching is a very complex field. I recommend beginning with the book "High Performance Web Sites" and follow yahoo performance blog.


As they go x10 is pretty good for a fee web host, any real speed issue is going to be with MSQL if your site uses a large database.

Getting all your javascript (.js)and css into external files [hosted wherever] so they can be cached inside the visitors browser for re-use is a good place start. (most people know that images cache, but are often unaware that css and js files cache also)

Another useful trick is that of Client Side Includes, whereby chunks of html that would normally have to be moved from the server to visitor every time the page loads can also cached inside the browser by wrapping the html inside a javascript file.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号