如何从我的网站缓存脚本和图像? [英] How to cache scripts and images from my site?
问题描述
问题::::::
我一直在尝试创建一个网站(托管在x10hosting上)。所以我一直在寻找如何建立一个快速网站。我有一个页面来改进Jquery代码。以下是该页面的链接。
在该页面中,我读到了包含来自Google.com的Jquery框架代码可以加速该网站。我也发现它的原因,因为Google.com缓存了Jquery框架代码,因此用户不必一次又一次下载Jquery框架代码。所以我想我也可以用我的网站做到这一点。那么我使用基于Linux的网站。所以任何人都可以建议一个页面或代码来缓存脚本或图片在我的网站,以便用户不必一次又一次地下载。
Links ::::::
微调缓存是一个非常复杂的领域。 这里是一个涉及在Apache上缓存图像的问题。堆栈溢出有关于此的各种现有问题。
如果您想一般考虑加速您的网站,请查看以下问题:优化以减少网站加载时间
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::::::
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.
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
这篇关于如何从我的网站缓存脚本和图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!