wbraswell / cloudforfree.org

Website for CloudForFree
7 stars 4 forks source link

Lack of asset caching causes sustained latency #6

Open kentfredric opened 7 years ago

kentfredric commented 7 years ago

Analysis by : http://www.webpagetest.org/result/161227_0K_ZNE/1/performance_optimization/

Indicates most of the assets don't have cache controls specified, so they'll likely be refreshed frequently, which will explain:

  1. User side episodic lag as assets are pointlessly refreshed
  2. Server side load as effort is spent in uselessly resending assets
  3. Additional lag as users vy for server time in fetching cacheable assets.
wbraswell commented 7 years ago

@kentfredric Okay is this specific to the web server software (Apache vs PSGI Plack, etc)... Or do we somehow enable caching from within Catalyst itself?

kentfredric commented 7 years ago

Its controlled with headers, which is controlled by whatever your web server software lets you touch.

Headers can be sent within the framework, usually, but can also be sent by the server software.

So "All of the above, it just depends on where the stuff comes from"

wbraswell commented 7 years ago

Okay well then I have no idea... We use Catalyst which is currently running via PSGI Starman, and in the near future we will switch over to Apache FastCGI. Can you please help point me in the right direction?

kentfredric commented 7 years ago

Cache controls are a broad subject, and are themselves only regulated by the ability to define HTTP headers. What headers you set and what values you set them to all depends on what you're doing.

For example, this page covers some, but some of the headers you see there are indications to fastly's middleware platform.

https://docs.fastly.com/guides/tutorials/cache-control-tutorial

But there's more docs here: https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching And here: https://www.keycdn.com/blog/http-cache-headers/

How you do that in Catalyst is subject to catalyst, which I haven't looked at for several years now.

But a quick google gives me: http://wiki.catalystframework.org/wiki/adventcalendararticles/2007/11-Making_your_Catalyst_App_Cache-friendly