Sitemde neden kod çalışmıyorWhy my site runs no code
· Sezer Kuşku · TeknikTechnical
sezlab.dev’in sayfaları tamamen statik: biri sayfayı açtığında sunucuda çalışan bir kod yok, yalnızca hazır dosyalar gidiyor. Bu bilerek verdiğim bir karar.
Ortak kota
Site Cloudflare Workers’ta duruyor. Ücretsiz planda kod çalıştıran isteklerin günlük bir sınırı var ve bu sınır hesaptaki bütün sitelerle ortak. Her ziyarette kod çalışsaydı, bir saldırı ya da çok ziyaret alan bir oyunun sayacı bu hakkı doldurup ana siteyi de kapatabilirdi.
Hazır dosya istekleri bu sınıra sayılmıyor. Yani site statik kaldıkça, başka bir şey ne kadar yoğun olursa olsun ana sayfa açılmaya devam ediyor.
Peki dinamik şeyler?
Gerektiğinde kodu yalnızca o işin adresinde çalıştırıyorum: oyunların skor tabloları, kaç kişinin aynı anda sitede olduğu, Kaynak evrenindeki terminal. Her biri dar bir adreste duruyor; geri kalan her şey düz dosya.
Bedeli
Her şeyi önceden üretmek gerekiyor. Ana sayfa bir betikle üretiliyor; bu blog da öyle: yazılar düz metin dosyaları, sayfalar onlardan bir kez üretilip yayına konuyor. Karşılığında site hızlı, ucuz ve bir yerde bir şey bozulduğunda ayakta kalıyor.
sezlab.dev’s pages are completely static: when someone opens a page, no code runs on the server; only ready-made files are sent. That’s a deliberate choice.
A shared quota
The site lives on Cloudflare Workers. On the free plan, requests that run code have a daily limit, and that limit is shared by every site on the account. If code ran on every visit, an attack or the counter of a busy game could use it up and take the main site down with it.
Requests for ready-made files don’t count towards that limit. So as long as the site stays static, the home page keeps opening no matter how busy something else gets.
What about dynamic things?
When I need code, I run it only at the address that needs it: leaderboards for the games, how many people are on the site right now, the terminal in the Source universe. Each sits on a narrow address; everything else is plain files.
The price
Everything has to be built ahead of time. The home page is generated by a script, and so is this blog: posts are plain text files, and the pages are built from them once and then published. In return the site is fast, cheap, and stays up when something somewhere breaks.
EtiketlerTags: statik sitestatic site, cloudflare
Yorumlar kapalıComments are closed
Söyleyeceğin bir şey varsa bana yaz: merhaba@sezlab.devIf you have something to say, write to me: hello@sezlab.dev