A lightweight, flexible PHP proxy server with intelligent caching capabilities for web content. Designed to improve website performance by caching HTML and JSON resources.
Important
This proxy server is designed for development and moderate production use. For high-traffic applications, consider additional scaling strategies and monitoring.
- π High Performance: Caches responses to reduce server load and improve response times
- π¦ Content-Type Aware: Intelligently caches HTML and JSON
- β‘ Configurable TTL: Different cache durations for different content types
- π Security: Domain blacklisting and request validation
- π Cache Statistics: Built-in monitoring and statistics generation
- π οΈ Easy Configuration: Simple setup and customization
| Content Type | Default TTL | Description |
|---|---|---|
| HTML | 1 Hour | Web pages and HTML content |
| JSON | 1 Hour | API responses and data |
git clone https://github.com/Mohammadreza-73/Phoxy.git
cd Phoxy# Check if cURL is enabled
php -m | grep curlchmod 755 cache/
chmod 755 cache/*/php -S localhost:8000Edit src/config/cache.php to customize the proxy behavior:
// Frontend JavaScript usage
fetch('/proxy.php?url=' + encodeURIComponent('https://example.com/api/data'))
.then(response => response.json())
.then(data => console.log(data));// Sending POST data through proxy
fetch('/proxy.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
url: 'https://api.example.com/submit',
data: { /* your payload */ }
})
});| Parameter | Required | Description |
|---|---|---|
url |
Yes | The target URL to proxy (URL encoded) |
| Header | Description |
|---|---|
X-Proxy-Cache |
HIT if served from cache, MISS if fetched fresh |
Access-Control-Allow-Origin |
* (CORS enabled) |
- Domain Blacklisting: Block specific domains
- Content Length Limits: Prevents large file attacks
- Timeout Protection: Limits request duration
- CORS Headers: Proper cross-origin handling
- Header Filtering: Removes sensitive headers from responses
- API Aggregation: Combine multiple APIs with caching
- Content Mirroring: Cache external resources for faster access
- Cross-Origin Requests: bypass CORS limitations for development
- Performance Optimization: Reduce load times for external resources
- Offline Development: Cache responses for development without internet
caching-proxy-server/
βββ cache/ # Cache storage directory
βββ logs/ # Store logs in `app.log`
βββ src/ # Source directory
β βββ config/ # Cache configuration settings
β βββ helpers/ # Helper functions
β βββ FileCache.php # Class to handle cache files
β βββ ProxyServer.php # Class to manage Proxy Server
β βββ Response.php # Class to handle HTTP resposne
βββ .editorconfig # config for editors
βββ index.php # Serve project
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Check the issues page
- Create a new issue with detailed description
This project is licensed under the MIT License - see the License File file for details.
