Interview Handbook by Sayed Elmahdy English

المحور 24 · أساسيات بتفرّق معاك

HTTP و Networking

رحلة الـ request، و DNS، و TCP، و TLS، و HTTP/1.1 و 2 و 3، و Headers، و Cookies، و Proxies.

16 سؤالJunior · 6Mid · 6Senior · 410 اختيارات

المفاهيم

هنفهم إيه؟ لما صفحة ما تفتحش أو تتأخر، هتفصل الرحلة من إلى response: اسم النطاق، الاتصال، ، ثم التطبيق. ده يخليك تميّز timeout في عن رفض من السيرفر، وتختار أدوات تشخيص أو أسلوب اتصال مناسباً للمشكلة.

قبل ما تبدأ: client يرسل request إلى server ويرجع response؛ URL يحدد البروتوكول والمضيف والمسار. يحدد عنواناً على الشبكة، وport يحدد خدمة على الجهاز. ما تحتاجش خبرة شبكات سابقة؛ نمشي خطوة بخطوة ونعرّف المصطلحات عند أول استخدام.

المصطلحات اللي تحتها خط منقّط تقدر تضغط عليها لمعرفة معناها، وترجع تكمل من نفس مكانك.

#من كتابة URL لحد ظهور الصفحةFrom typing a URL to rendering a page

مثال خطوة بخطوة
  1. كتبت عنوان متجر في المتصفح. أولًا يحتاج يعرف أين يرسل الطلب؛ يحل اسم النطاق لسجلات منها عنوان السيرفر، وقد تكون النتيجة موجودة في كاش.
  2. في رحلة شائعة فوق ، يُنشأ الاتصال ثم يحميه ويتحقق من هوية الطرف، وبعده يُرسل طلب . اتصالات أو جلسات موجودة قد تقلل خطوات الإنشاء.
  3. يرجع الرد فيقرأ المتصفح الصفحة وقد يطلب ملفات إضافية. HTTP/3 يستخدم فوق ، فالرسم ده مثال لمسار شائع وليس ترتيب TCP إلزاميًا لكل نسخة من HTTP.

لما صفحة بتتأخر، «الشبكة بطيئة» تشخيص واسع. اقسم الرحلة لمراحل علشان تعرف هل المشكلة DNS ولا connection ولا server ولا rendering. دي رحلة HTTPS نموذجية على TCP؛ connection reuse و caches ممكن يختصروا خطوات، و HTTP/3 بيستخدم QUIC بدل TCP.

  1. المتصفح يحلل scheme و host و port و path، ويراجع cache وسياسات زي و service worker لو موجود.
  2. DNS: يراجع caches المحلية، ثم recursive resolver. لو مفيش إجابة cached، الـ resolver ممكن يسأل root عن TLD، ثم TLD عن authoritative nameserver، ثم authoritative عن record، ويتابع aliases. مش كل زيارة بتكرر السلسلة.
  3. TCP: العميل يبعت SYN، والسيرفر SYN-، والعميل ACK. بورت العميل غالباً ephemeral، والوجهة HTTPS غالباً 443.
  4. TLS 1.3: ClientHello يعلن capabilities و key share، والسيرفر يرد باختيار و key share وشهادة ورسائل إثبات الهوية. العميل يتحقق من hostname والثقة، والاتنين يشتقوا مفاتيح التشفير. ALPN بيتفاوض على HTTP protocol.
  5. العميل يبعت HTTP request مشفر، والـ server أو proxy يرجع status و headers و body.
  6. المتصفح يحلل و CSS، ويبني DOM و CSSOM، ويحمّل resources، وينفذ JavaScript، ويعمل layout و paint. بعض الشغل بيتداخل بدل انتظار كل resource.
TLS 1.3 full handshake عادة محتاج round trip واحدة للـ TLS فوق TCP الجديد. resumption و0-RTT ممكن يقللوا البداية، لكن early data معرضة للـ replay، فمش مكان مناسب لعملية دفع غير آمنة للتكرار.

#Layers و TCP و UDP و SocketsLayers, TCP, UDP and sockets

الـ layers بتفصل المسؤوليات، وبتساعدك تفهم ليه نجاح ping مش دليل إن شغالة. OSI نموذج 7 layers: Physical، و Data link، و Network، و Transport، و Session، و Presentation، و Application. نموذج / العملي غالباً بيجمعهم في Link، و Internet، و Transport، و Application؛ مش لازم يتحشر في mapping حرفي واحد.

TCP
الداتاbyte stream موثوق ومرتب، من غير حدود messagesdatagrams بحدود واضحة، من غير ضمان وصول أوترتيب
التحكمretransmission و flow control و congestion controlمش بيوفر دول كتسليم مضمون؛ protocol فوقه ممكن يضيفهم
أمثلة/1.1، و HTTP/2 غالباً، و ، و media protocols

port رقم endpoint منطقي لخدمة transport، و socket abstraction في الـ للاتصال. اتصال TCP بيتحدد بالـ source IP والـ source port والـ destination IP والـ destination port مع protocol. سيرفر واحد يقدر يخدم اتصالات كتير على 443 لأن client endpoints مختلفة.

TCP read واحدة مش لازم تساوي message واحدة؛ لازم framing على مستوى التطبيق. UDP مش «أسرع دائماً»، و QUIC بيضيف reliable streams و congestion control فوقه. DNS ممكن يستخدم TCP كمان؛ ماتحفظش protocol كبورت و transport واحد فقط.

#HTTP request و Methods و Status codesHTTP requests, methods and status codes

semantics بتقول intent العملية، مش بس شكل . GET و HEAD safe و ؛ PUT و DELETE idempotent في الأثر المقصود، مش شرط نفس الرد؛ POST مش idempotent افتراضياً؛ PATCH حسب العملية والتصميم. safe معناها مفيش تغيير business مطلوب من العميل، مش منع logs أو metrics.

العيلةالمعنى وأمثلة
1xxمعلومات مؤقتة زي 100 Continue
2xx200 نجاح، و201 إنشاء، و202 قبول لمعالجة لاحقة، و204 من غير body
3xxredirect أو cache validation؛ 304 مش redirect لمكان جديد
4xx400 طلب غير صالح، و401 credentials ناقصة أوغير صالحة، و403 مرفوض، و404 مش موجود، و409 تعارض، و429 rate limit
5xx500 خطأ داخلي، و502 upstream response غير صالح، و503 غير متاح، و504 upstream timeout

المثال raw HTTP/1.1 للعرض؛ الـ wire محتاج CRLF و transport لو endpoint محمية. Content-Type بيصف body المرسل، و Accept بيقول إيه أنواع الرد المقبولة.

GET /products/42 HTTP/1.1
Host: store.example.com
Accept: application/json
If-None-Match: "product-v7"

HTTP/1.1 304 Not Modified
ETag: "product-v7"
Cache-Control: public, max-age=60

الـ client عنده representation بنفس ETag، فالـ server رجّع 304 من غير body. header names مش case-sensitive. ماتعيدش POST بعد timeout بشكل أعمى؛ الطلب ممكن يكون اتنفذ والرد ضاع. استخدم idempotency key بعقد واضح لو retry محتاج يضمن عدم تكرار الأثر.

#HTTP/1.1 و HTTP/2 و HTTP/3 في KestrelHTTP/1.1, HTTP/2 and HTTP/3 in Kestrel

تحميل resources كتير على connection واحدة محتاج multiplexing. /2 بيحل انتظار الطلبات على مستوى HTTP، لكن فقد packet لسه ممكن يوقف streams كلها لحد استرجاعها. HTTP/3 بينقل streams على ؛ فقد داتا stream مش لازم يمنع تسليم داتا stream تانية.

HTTP/1.1HTTP/2HTTP/3
TransportTCPTCPQUIC فوق
Requestspersistent connections؛ pipelining محدود عملياًbinary frames و multiplexed streamsmultiplexed QUIC streams
Headerstext من غير HPACKHPACKQPACK
LossTCP ordering يوقف الداتا اللاحقةTCP head-of-line blocking بين streamsبيقلل transport blocking بين streams، مع shared congestion لسه

ده Program.cs كامل لـ 10 web project. محتاج default certificate مضبوطة؛ HTTP/3 محتاج platform و MsQuic مدعومين، و UDP port مفتوح كمان.

using Microsoft.AspNetCore.Server.Kestrel.Core;

var builder = WebApplication.CreateBuilder(args);
builder.WebHost.ConfigureKestrel(options =>
{
    options.ListenAnyIP(5001, listen =>
    {
        listen.Protocols = HttpProtocols.Http1AndHttp2AndHttp3; // (1)
        listen.UseHttps(); // (2)
    });
});
var app = builder.Build();
app.MapGet("/", (HttpContext context) => context.Request.Protocol); // (3)
app.Run();
🧾 شرح الكود
  1. (1) بنسمح بالبروتوكولات، لكن العميل والـ proxy والـ لازم يدعموها.
  2. (2) للتفاوض؛ HTTP/3 بيعتمد على TLS 1.3 في QUIC. ماتحطش certificate password في source.
  3. (3) النتيجة بتساعد تتحقق من البروتوكول عند Kestrel؛ public edge ممكن يكون بيتكلم HTTP/3 مع العميل و HTTP/1.1 مع التطبيق.

HTTP semantics واحدة عبر الإصدارات؛ HTTP/3 مش أسرع دائماً، و UDP ممكن يتقفل في بعض الشبكات فـ fallback مهم. HTTP/3 specification و متطلبات Kestrel.

#Keep-alive و Connection pooling و Socket exhaustionKeep-alive, connection pooling and socket exhaustion

و handshakes ليهم تكلفة. /1.1 بيعيد استخدام connections افتراضياً، و HTTP/2 يقدر يشارك connection بين streams. HTTP keep-alive مختلف عن TCP keepalive probes اللي بتكشف اتصال خامل ميت. إنشاء HttpClient بـ handler جديد لكل request بيهدر pools وممكن يستهلك ephemeral ports تحت الحمل.

المثال داخل 10 application مع و Microsoft.Extensions.Http. resolve العميل بالـ factory؛ ماتحتفظش بـ factory-created client للأبد لو معتمد على handler rotation لتحديث .

builder.Services.AddHttpClient("catalog", client =>
{
    client.BaseAddress = new Uri("https://catalog.example.com");
    client.Timeout = TimeSpan.FromSeconds(10); // (1)
}).ConfigurePrimaryHttpMessageHandler(() => new SocketsHttpHandler
{
    PooledConnectionLifetime = TimeSpan.FromMinutes(5), // (2)
    MaxConnectionsPerServer = 20 // (3)
});

// Inside a service receiving IHttpClientFactory factory:
using var client = factory.CreateClient("catalog");
using var response = await client.GetAsync("/products/42", cancellationToken);
response.EnsureSuccessStatusCode();
🧾 شرح الكود
  1. (1) timeout محدد، ومعاه cancellation من المستدعي.
  2. (2) connections القديمة تتقاعد علشان connections جديدة تعمل DNS resolution جديد؛ HttpClient مش بيتتبع DNS لكل request. الخمس دقايق مثال محتاج يتناسب مع البيئة.
  3. (3) سقف connections، مش بالضرورة سقف requests مع multiplexing. التزامن محتاج حدود مناسبة كمان.

بديل صحيح: long-lived HttpClient مع SocketsHttpHandler و connection lifetime مناسبة. خلص أو dispose responses خصوصاً streaming علشان الموارد ترجع. retries لازم تبقى محدودة وآمنة للأثر، مش علاج تلقائي لكل timeout. إرشادات HttpClient.

#Cookies و Tokens و CORSCookies, tokens and CORS

cookie آلية تخزين وإرسال في المتصفح؛ دليل هوية أوصلاحية، وممكن يتخزن في cookie. فالمقارنة مش نوعين متضادين. Secure يقيد إرسال cookie على ، و HttpOnly يمنع قراءتها من JavaScript، و SameSite بيقيد إرسالها في سياقات cross-site. HttpOnly مش مانع إن ينفذ طلبات بصلاحيات المستخدم.

المثال raw response header؛ الـ session value لازم يطلع من نظام authentication، والقيمة هنا placeholder فقط.

Set-Cookie: session=SESSION_VALUE; Path=/; Secure; HttpOnly; SameSite=Lax

SameSite=None محتاج Secure للمتصفحات الحديثة، وسياسات third-party cookies ممكن تمنع الإرسال برضه. cookie auth محتاجة defense حسب السيناريو؛ bearer token صريح في Authorization مش بيتبعت تلقائياً بنفس الطريقة، لكن تخزينه المتاح لـ JavaScript بيزود أثر XSS.

سياسة متصفح للسماح بقراءة responses بين origins. origin هي scheme و host و port، ومش هي site بالضبط. المثال registration و داخل app؛ حطه بعد routing وقبل authorization.

builder.Services.AddCors(options => options.AddPolicy("store", policy =>
    policy.WithOrigins("https://shop.example.com") // (1)
        .WithMethods("GET", "POST")
        .WithHeaders("Content-Type")
        .AllowCredentials())); // (2)

// After builder.Build() and routing:
app.UseCors("store");
🧾 شرح الكود
  1. (1) allowlist محددة بدل لأي Origin.
  2. (2) credentialed requests محتاجة origin صريحة، مش wildcard. المتصفح محتاج opt-in للـ credentials، والـ cookie policies لسه بتتطبق.

preflight عادة OPTIONS قبل طلب غير بسيط. CORS مش authentication ولا firewall؛ curl والـ server clients مش مقيدين بيها، وبعض الطلبات cross-origin بتتوصل حتى لو المتصفح منع قراءة الرد. CORS protocol.

#Caching headers و CompressionCaching headers and compression

cache صح بتقلل وحمل السيرفر، و cache غلط ممكن تسرب داتا مستخدم. max-age بيحدد freshness، و public يسمح shared cache، و private يخصصه للـ user cache. no-cache معناها لازم revalidation قبل إعادة الاستخدام، مش منع التخزين؛ no-store بيمنع التخزين. ETag مع If-None-Match ممكن يرجع 304 من غير body.

HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: public, max-age=60
ETag: "catalog-v8"
Vary: Accept-Encoding
Content-Encoding: br

[Brotli-compressed representation bytes]

المثال schematic لكتالوج عام؛ body المعروضة وصف للبايتات مش قابل للإرسال. Vary يحدد request headers اللي تغير representation ومفتاح cache. compression بتتفاوض بـ Accept-Encoding، و br أو gzip بتوفر bandwidth مقابل ؛ الصور المضغوطة غالباً مش هتستفيد.

ماتحطش authenticated invoice تحت public cache. ضبط cache key للـ query والـ locale والـ tenant حسب المحتوى أساسي. ضغط responses اللي بتخلط secret مع input تحت سيطرة مهاجم ممكن يعمل side channel؛ قيّم النوع ده بدل تفعيل compression على كل حاجة.

no-store مايمسحش نسخ قديمة اتخزنت بالفعل. invalidation وسياسات browser و محتاجة تصميم متوافق. HTTP caching specification.

#Proxies و Load balancers و CDNsProxies, load balancers and CDNs

forward proxy بيمثل العميل في الخروج؛ بيمثل السيرفرات قدام العميل. load balancer بيوزع اتصالات أوطلبات؛ بتقرب delivery من المستخدم وبتقدر تعمل cache و edge functions حسب المنتج.

L4 load balancingL7 load balancing
القرار و port و transport connection host و path و headers بعد فهم البروتوكول
ممكن pass-through؛ التفاصيل حسب المنتجغالباً termination ثم TLS جديد أو HTTP للـ upstream
الاستخدامtraffic عام مش لازم HTTProuting للـ و header policies

TLS termination معناها إن فيه trust boundary جديدة بين proxy والتطبيق. اضبط trusted forwarded headers، وحدود body، و timeouts، و . CDN cache للـ static assets مفيد، لكن cookies و Authorization و query parameters لازم تتفهم علشان cache key مايسربش داتا. sticky sessions مش بديل عن shared state، و load balancer مش بيضمن إن عملية دفع تتنفذ مرة واحدة.

#DNS records و TTL و IPv4 و IPv6 و NATDNS records, TTL, IPv4, IPv6 and NAT

بيربط أسماء بمعلومات، مش مجرد بـ . مدة السماح بتخزين record في cache، مش مدة الاتصال ولا ضمان إن كل العملاء هيحولوا في نفس اللحظة.

Recordالمعنى
Aاسم إلى IPv4
AAAAاسم إلى IPv6
CNAMEاسم alias لاسم تاني، مش URL ولاredirect
MXmail servers وأولوياتها
TXTنص زي verification و SPF policies

IPv4 عنوان 32-bit، و IPv6 عنوان 128-bit. private IPv4 ranges هي 10.0.0.0/8، و 172.16.0.0/12، و 192.168.0.0/16. loopback زي 127.0.0.1 مختلف عن private LAN. في IPv6 فيه loopback ::1، و unique-local تحت fc00::/7، و link-local تحت fe80::/10.

بيترجم عناوين، و PAT بيشارك public IP باستخدام ports؛ ده مش encryption ولا بديل عن firewall. IPv6 مش معناه كل endpoint مفتوحة: policies لسه لازمة. في dual-stack اختبر العيلتين؛ AAAA غلط ممكن يعمل تأخير حتى لو A شغالة. تقليل TTL قبل failover مفيد، لكنه مش بيقفل connections قديمة موجودة في pools.

#WebSockets و SSE و أدوات التشخيصWebSockets, SSE and diagnostic tools

polling المتكرر بيهدر طلبات لما مفيش جديد. WebSocket بيوفر channel ثنائي الاتجاه برسائل فوق connection طويلة؛ stream نصي من السيرفر للعميل باستخدام text/event-stream، والمتصفح بيدعم reconnect عبر EventSource. WebSocket مش محصور دائماً في /1.1 Upgrade؛ فيه آليات للإصدارات الأحدث حسب دعم الـ stack.

الاحتياجاختيار مناسب
حالة order بتتحدث من السيرفرSSE، لو اتجاه واحد كفاية
تبادل messages لحظي في الاتجاهينWebSocket أو SignalR abstraction
تحديث قليل وغير حساسpolling بسيط ممكن يكون كفاية

10 بيوفر TypedResults.ServerSentEvents. في أي stream اضبط cancellation و و heartbeats و proxy buffering و idle timeouts؛ reconnect محتاج event IDs و replay policy لو فقد events مش مقبول.

الأوامر Bash مع curl؛ endpoint أمثلة وليست خدمة شغالة هنا. بعض flags زي HTTP/3 محتاجة curl build مناسب؛ افحص curl --version.

curl -I https://store.example.com/products/42       # (1)
curl -v --http2 https://store.example.com/products/42 # (2)
curl --compressed https://store.example.com/products/42
curl -N -H 'Accept: text/event-stream' \
  https://store.example.com/orders/42/events        # (3)
curl --resolve store.example.com:443:192.0.2.10 \
  https://store.example.com/products/42             # (4)
🧾 شرح الكود
  1. (1) HEAD بيطلب metadata من غير body.
  2. (2) verbose يوضح negotiation و headers؛ ماتشاركش logs فيها credentials. راقب البروتوكول الفعلي، مش flag بس.
  3. (3) -N بيوقف output buffering في curl علشان تشوف events فور وصولها.
  4. (4) تجاوز لعنوان توثيقي مع الحفاظ على hostname و verification؛ مفيد لاختبار routing بعد استبداله بعنوان test حقيقي.

curl مش متصفح: نجاحه مش دليل على أو cookie behavior في المتصفح. افصل اختبار DNS و TLS و HTTP و application behavior.

أسئلة الانترفيو

راجع فهمك

ليه الاختيار ده مناسب؟ إمتى ممكن ماينفعش؟ وإيه اللي هيتغير لو الحمل زاد أو ظهر فشل؟

24.1What happens when you type an HTTPS URL into a browser?Junior

تحليل ، و caches، و ، و و لو connection جديدة، و ، وبعدين parsing و layout و paint. HTTP/3 بيغير transport.

الإجابة النموذجية (English)

I break it into stages. The browser parses the and checks relevant caches, resolves the hostname, establishes a connection if one cannot be reused, and negotiates for . It sends the request, receives headers and content, then parses resources and performs rendering. For -based HTTPS there is a TCP handshake before TLS; HTTP/3 uses instead. Caching and connection reuse can skip substantial parts of this sequence.

24.2How do TCP and UDP differ?Junior

ordered reliable byte stream من غير message boundaries؛ datagrams من غير ضمان الوصول. protocol فوق UDP ممكن يضيف reliability.

الإجابة النموذجية (English)

I use when I need a reliable ordered byte stream, understanding that application messages still require framing. preserves datagram boundaries but does not itself guarantee delivery or ordering. That can suit protocols that manage loss differently, such as real-time media or . I do not equate UDP with always faster or TCP with one packet per message; performance and correctness depend on the protocol built above the transport and the network conditions.

24.3What is the TCP three-way handshake?Junior

SYN ثم SYN- ثم ACK لتأسيس الاتصال وحالة sequence numbers. ده مش تشفير ولا authentication.

الإجابة النموذجية (English)

I describe it as the exchange of SYN, SYN- and ACK to establish connection state and synchronize sequence numbers in both directions. It lets each endpoint confirm communication with the other before normal stream exchange. It does not encrypt the connection or authenticate an application user. For , adds encryption and server authentication above TCP. Reusing an established connection avoids repeating this startup work for every request.

24.4What does TLS 1.3 provide?Mid

تشفير وسلامة الداتا وإثبات هوية السيرفر عادة بالشهادة. تحقق hostname و trust ضروري، و مش authorization للـ .

الإجابة النموذجية (English)

I rely on 1.3 for confidentiality, integrity and authentication of the server through certificate validation, with client authentication available when configured. The peers negotiate parameters and derive traffic keys rather than sending a shared secret in plaintext. A typical full handshake adds one TLS round trip over a new connection. TLS does not authorize business operations, and disabling certificate validation defeats a central part of its security even if traffic remains encrypted.

24.5How do HTTP/2 and HTTP/3 improve on HTTP/1.1?Mid

/2 multiplexing و HPACK فوق ؛ HTTP/3 streams فوق و QPACK لتقليل blocking بين streams عند الفقد.

الإجابة النموذجية (English)

I see /2's main improvements as binary framing, multiplexed streams and HPACK header compression over . That reduces HTTP-level , but TCP loss can still block progress across streams. HTTP/3 moves to over and uses QPACK, reducing that cross-stream transport blocking. It still has congestion and flow control, and is not automatically faster in every environment. I verify support through clients, proxies, firewalls and the server before enabling it.

24.6What does idempotent mean in HTTP?Junior

تكرار نفس الطلب ليه نفس الأثر المقصود زي مرة واحدة، مش شرط نفس status. DELETE تاني ممكن يرجع 404 ويظل .

الإجابة النموذجية (English)

I call an operation when repeating the same request has the same intended server-side effect as performing it once. Responses can differ: deleting an already deleted resource might return a different status without violating that property. PUT and DELETE have idempotent semantics, while POST does not inherently. For retryable payment creation, I define an idempotency-key contract and persist its outcome because a timeout cannot tell the client whether the first attempt completed.

24.7Why can creating HttpClient per request cause problems?Mid

لو handler جديد كل مرة، pools تتدمر و connections و ports تتستهلك. factory أو long-lived client مع lifetime مناسبين حلين صحيحين.

الإجابة النموذجية (English)

I avoid creating a new HttpClient and handler for every request because each handler owns connection pools. Repeated disposal wastes connections and can exhaust ephemeral ports under load. I use IHttpClientFactory for pooled handler management or a long-lived client with a suitable SocketsHttpHandler connection lifetime. I also bound requests and release response resources. Simply making the client static is incomplete if connections never refresh and changes need to be picked up.

24.8How does HttpClient react to DNS changes?Senior

بيتحل عند إنشاء connection، مش كل request حسب . lifetime أو handler rotation يسمحوا باتصالات جديدة؛ القديمة مش بتتقفل فور تغيير DNS.

الإجابة النموذجية (English)

I assume is resolved when a connection is established rather than before every request. Existing pooled connections can continue using the old destination after records change. PooledConnectionLifetime or suitable handler rotation allows new connections to resolve again, with an interval chosen for the environment. I also avoid indefinitely retaining factory clients when relying on rotation. Lowering DNS alone does not move traffic already traveling through an established connection.

24.9Is CORS a security boundary for an API?Mid

متصفح يتحكم في قراءة الرد، مش auth ولاحظر للـ server clients. حتى طلب ممكن يوصل والرد يتمنع.

الإجابة النموذجية (English)

I treat as a browser-enforced policy for cross-origin response access, not authentication or a network firewall. Non-browser clients can call the endpoint regardless, and some requests can reach the server even when a browser blocks access to the response. I therefore enforce authorization and appropriate defenses independently. For credentialed browser requests I allow explicit trusted origins, methods and headers rather than combining wildcard origins with credentials.

24.10How do Secure, HttpOnly and SameSite cookies differ?Mid

Secure للإرسال على ، و HttpOnly لمنع قراءة JavaScript، و SameSite لتقييد cross-site sending. كل واحدة بتحل جزء مختلف.

الإجابة النموذجية (English)

I use Secure to restrict cookie transmission to , HttpOnly to prevent JavaScript from reading the cookie, and SameSite to control cross-site sending. None is complete protection by itself: HttpOnly does not stop malicious script from issuing authenticated requests, and SameSite does not replace every defense. Cross-site cookies using SameSite=None need Secure in modern browsers, and third-party-cookie policies can still block them. I test the actual browser flow rather than relying on curl.

24.11What is the difference between no-cache and no-store?Junior

no-cache يسمح التخزين لكن لازم validation قبل reuse؛ no-store يمنع التخزين. private مش معناها تشفير.

الإجابة النموذجية (English)

I use no-cache when a stored response must be revalidated before reuse, often through an ETag and a conditional request. I use no-store when the response should not be stored. They are not synonyms. I also distinguish private caching from shared caching: private limits where the response may be cached but does not encrypt it. For sensitive user data I review the full browser and policy rather than adding one directive without checking existing cache behavior.

24.12How does an ETag help caching?Mid

validator للـ representation؛ client يبعت If-None-Match، ولو مطابقة يرجع 304 من غير body مع metadata مناسبة.

الإجابة النموذجية (English)

I use an ETag as a validator for a selected representation. A client sends it in If-None-Match, and the server can return 304 without a body if the representation is still valid. That saves transfer while still involving a validation request. I ensure the tag reflects the content and that cache keys account for meaningful variants. I also distinguish weak and strong validators when exact byte equality or conditional update semantics matter.

24.13How do L4 and L7 load balancers differ?Senior

L4 حسب connection و و port؛ L7 بيفهم و host و path و headers. ممكن ينتهي عنده أويمر حسب المنتج.

الإجابة النموذجية (English)

I use L4 balancing for transport-level distribution based on addresses, ports and connections. L7 balancing understands application protocols and can route by host, path or headers. That enables richer policies but usually introduces additional application-level configuration and often termination. I check where encryption ends and how client information is forwarded. Neither type removes the need for readiness, graceful draining or application-level when requests fail during a connection change.

24.14When would you choose SSE over WebSockets?Senior

لو server-to-client text events كفاية؛ WebSockets للاتجاهين. في الاتنين راجع proxy timeouts و و reconnect semantics.

الإجابة النموذجية (English)

I choose for a server-to-client event stream such as order-status updates when bidirectional messaging is unnecessary. Browser EventSource provides reconnection behavior, but reliable recovery still needs event identifiers and a replay policy. I choose WebSockets when the client and server both need interactive messages. For either approach I test proxy buffering, idle timeouts, cancellation, and authentication lifecycle rather than assuming a persistent connection automatically guarantees reliable message delivery.

24.15What do A, AAAA and CNAME DNS records mean?Junior

A لـ IPv4، و AAAA لـ IPv6، و CNAME alias لاسم تاني. مش redirect ولاpath mapping.

الإجابة النموذجية (English)

I use A records to map a name to an IPv4 address and AAAA records for IPv6. A CNAME aliases one name to another name; it does not contain a path or issue an redirect. Resolution can follow that alias to address records. I also consider and existing connection pools during changes, because publishing a new record does not mean every resolver and connected client immediately uses the new destination.

24.16A request works in curl but fails in the browser. What do you inspect?Senior

قارن origin و preflight و credentials و cookie policies و mixed content و certificate trust. curl success مش إثبات إن browser flow صح.

الإجابة النموذجية (English)

I compare the exact requests and inspect the browser network and console output. I check origin, preflight, allowed headers, credentials mode, cookie attributes and third-party-cookie policy, along with mixed-content and certificate errors. I also verify whether the server received the request or only a preflight. curl does not enforce browser rules, so its success establishes reachability and an response, not correctness of the browser security and authentication flow.

اختبر نفسك

إجابات الاختبار وعلامات إكمال المحاور بتتحفظ على المتصفح ده، ومش بتتنقل لأجهزة تانية.

النتيجة: 0 / 0

Which sequence describes the TCP three-way handshake?

دي خطوة ، والـ فوقها في على TCP.

HTTP/3 uses which transport?

بيضيف reliable streams وبيستخدم 1.3.

Which directive requires validation before reuse but permits storage?

no-store هي اللي بتمنع التخزين.

CORS primarily controls what?

auth و و network policy مسؤوليات مستقلة.

What does HttpOnly prevent?

script ممكن ينفذ requests حتى لو مش قادر يقرا cookie.

What does a 304 response normally omit?

الـ client يعيد استخدام representation الموجودة بعد التحقق.

Which record maps a hostname to IPv6?

A لـ IPv4، و AAAA لـ IPv6.

Why can HTTP/2 streams stall together after packet loss?

head-of-line blocking لسه موجود تحت multiplexing.

An HTTP POST timed out. What is safe to assume?

ممكن التنفيذ حصل والرد ضاع؛ contract مهمة.

What does lowering DNS TTL fail to do by itself?

cache و connection pool آليتين مختلفتين.