Responsive Design is a web design approach that allows a website to automatically adjust to different screen sizes and devices. This ensures a seamless user experience across desktops, tablets, and smartphones without needing separate versions of the site.
Responsive Design is achieved using the following techniques:
1. Flexible Layouts
2. Media Queries (CSS)
@media (max-width: 768px) {
body {
background-color: lightgray;
}
}
→ This changes the background color for screens smaller than 768px.
3. Flexible Images and Media
img {
max-width: 100%;
height: auto;
}
4. Mobile-First Approach
✅ Better user experience across all devices
✅ SEO advantages, as Google prioritizes mobile-friendly sites
✅ No need for separate mobile and desktop versions, reducing maintenance
✅ Higher conversion rates, since users can navigate the site easily
Responsive Design is now the standard in modern web development, ensuring optimal display and usability on all devices.
A Bearer Token is a type of access token used for authentication and authorization in web applications and APIs. The term "Bearer" means "holder," which implies that anyone in possession of the token can access protected resources—without additional verification.
Authorization: Bearer <token>
.GET /protected-data HTTP/1.1
Host: api.example.com
Authorization: Bearer abcdef123456
💡 Tip: To enhance security, use short-lived tokens and transmit them only over HTTPS.
OAuth (Open Authorization) is an open standard protocol for authorization that allows applications to access a user's resources without knowing their credentials (e.g., password). It is commonly used for Single Sign-On (SSO) and API access.
OAuth operates using tokens, which allow an application to access a user's data on their behalf. The typical flow is as follows:
The View is the presentation layer in the MVC architecture. It is responsible for displaying data from the Model in a user-friendly format.
✅ Displaying Data: Shows information from the Model (e.g., a list of blog posts).
✅ Reacting to User Interactions: Accepts user input and sends it to the Controller.
✅ Formatting & Layout: Structures content using HTML, CSS, or templating engines (e.g., Laravel Blade or Twig).
✅ Avoiding Business Logic: Contains only presentation logic, not data processing.
<!-- resources/views/blog/index.blade.php -->
@extends('layouts.app')
@section('content')
<h1>Blog Posts</h1>
@foreach ($posts as $post)
<div>
<h2>{{ $post->title }}</h2>
<p>{{ $post->content }}</p>
</div>
@endforeach
@endsection
🔹 @foreach
: Loops through the list of blog posts and displays them.
🔹 {{ $post->title }}
: Outputs the title of the blog post.
✔ The View is responsible for presentation but does not process data.
✔ It ensures a clear separation between logic and display.
✔ Using templates or frontend technologies (e.g., Vue.js, React), the View can be dynamically rendered.
The Model is the data and logic layer in the MVC architecture. It manages the application's data and ensures that it is correctly stored, retrieved, and processed.
✅ Data Management: Stores and handles data, often in a database.
✅ Business Logic: Contains rules and calculations (e.g., discount calculation for orders).
✅ Data Validation: Checks if input is correct (e.g., if an email address is valid).
✅ Database Communication: Performs CRUD operations (Create, Read, Update, Delete).
class BlogPost extends Model {
protected $fillable = ['title', 'content']; // Erlaubte Felder für Massenverarbeitung
// Beziehung: Ein Blogpost gehört zu einem Benutzer
public function user() {
return $this->belongsTo(User::class);
}
}
🔹 fillable
: Specifies which fields can be saved.
🔹 belongsTo(User::class)
: Indicates that each blog post belongs to a user.
✔ The Model handles all data and business logic of the application.
✔ It ensures a clear separation between data and presentation.
✔ Changes to the data structure only need to be made in the Model, not throughout the entire application.
A Controller is a key component in the Model-View-Controller (MVC) architecture. It acts as an intermediary between the user interface (View) and the business logic or data (Model).
Handling User Input
Processing the Request
Interacting with the Model
Updating the View
Suppose a user wants to create a new blog post:
class BlogController extends Controller {
public function store(Request $request) {
// Validierung der Benutzereingabe
$request->validate([
'title' => 'required|max:255',
'content' => 'required',
]);
// Neues Blog-Post-Model erstellen und speichern
BlogPost::create([
'title' => $request->input('title'),
'content' => $request->input('content'),
]);
// Weiterleitung zur Blog-Übersicht
return redirect()->route('blog.index')->with('success', 'Post erstellt!');
}
}
✔ A controller manages the flow of an application and separates business logic from presentation.
✔ It ensures clean code structure, as each component (Model, View, Controller) has a specific responsibility.
✔ Modern frameworks like Laravel, Django, or ASP.NET often include built-in routing mechanisms that automatically direct requests to the appropriate controllers.
Model-View-Controller (MVC) is a software architecture pattern that divides an application into three main components:
✔ Better maintainability through a clear separation of concerns.
✔ Reusability of components.
✔ Easy testability since logic is separated from the interface.
✔ Flexibility, as different views can be used for the same model.
MVC is widely used in web and desktop applications, including:
Entity headers are HTTP headers that provide information about the body of a message. They can appear in both requests and responses, describing properties of the content such as type, length, encoding, or last modification date.
1.
Content-Type
Content-Type: application/json; charset=UTF-8
2.
Content-Length
Content-Length: 1024
3.
Content-Encoding
Content-Encoding: gzip
4. Content-Language
Content-Language: de-DE
5. Cache-Location
Content-Location: /files/document.pdf
6. Last-Modified
Last-Modified: Tue, 30 Jan 2025 14:20:00 GMT
7. ETag
ETag: "abc123xyz"
8. Expires
Expires: Fri, 02 Feb 2025 12:00:00 GMT
9. Allow
Allow: GET, POST, HEAD
10. Refresh
(Not standardized but often used)
Refresh: 10; url=https://example.com
These headers help describe the content of an HTTP message, optimize caching strategies, and ensure correct rendering.
Response headers are HTTP headers sent from the server to the client. They contain information about the server’s response, such as status codes, content types, security policies, or caching rules.
1. Server
Server: Apache/2.4.41 (Ubuntu)
2. Date
Date: Wed, 31 Jan 2025 12:34:56 GMT
3. Content-Type
Content-Type: text/html; charset=UTF-8
4. Content-Length
Content-Length: 3456
5. Cache-Control
Cache-Control: max-age=3600, must-revalidate
6. Set-Cookie
Set-Cookie: sessionId=abc123; Path=/; Secure; HttpOnly
7. ETag
ETag: "5d8c72a5f8d9f"
8. Location
Location: https://www.new-url.com/
9. Access-Control-Allow-Origin
Access-Control-Allow-Origin: *
10. Strict-Transport-Security
(HSTS)
Strict-Transport-Security: max-age=31536000; includeSubDomains
Response headers help the client interpret the received response correctly, enforce security measures, and optimize caching strategies.
Request headers are HTTP headers sent by a client (e.g., a web browser or API request) to the server, providing additional information about the request, the client, or the desired content.
1. Host
Host: www.example.com
2. User-Agent
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64)
3. Accept
Accept: text/html, application/json
4. Accept-Language
Accept-Language: de-DE, en-US
5. Accept-Encoding
Accept-Encoding: gzip, deflate, br
6. Referer
Referer: https://www.google.com/
7. Authorization
Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=
8. Cookie
Cookie: sessionId=abc123; theme=dark
9. Content-Type
(for POST/PUT-Anfragen)
Content-Type: application/json
10. Origin
Origin: https://www.example.com
These headers help the server understand the request and respond accordingly by providing details about the client, preferred content, and security aspects.