Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

bravioz's avatar

Using Forge managed server for caching

Hi guys,

I have this one project on a shared hosting and no possibility to use memcached in that environment. I was wondering that if I create a server to Digital Ocean through Forge, can I access its memcached? So basically access it from another network outside.

Do I just need to open memcached port and maybe enable access only from certain IP?

Any help appreciated!

0 likes
3 replies
fideloper's avatar
Level 11

Yep, you can do that!

That use case might be simple enough to do outside of Forge as well.

If you do use Forge, you'll get the security settings done for you - all you need to do is:

  1. Open up the memcached port 11211 to public connections (via firewall settings) OR (preferably) to the specific IP address of your servers accessing it (also via firewall settings)
  2. Ensure Memcached is listening on all networks, rather than just the localhost network. I think Forge does this by default:
$ ps aux | grep memcache
[stuff here]  Sl Aug11 1:39 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 0.0.0.0

In that command on a Forge server of mine, we can see memcache is running on 0.0.0.0, which means "all networks". We can confirm this:

$ netstat -a | grep 11211
tcp 0 0 *:11211 *:* LISTEN     
udp 0 0 *:11211 *:*

Great, so memcache is listening on port 1121 on all networks on port 11211 (*:11211) by default - that should be all set.

Consider this, however: Your use case will be making a network trip to the digital ocean server, which is NOT in the same data center (I'm assuming the shared hosting isn't based on digital ocean servers). You may not be saving response time unless the caching you use is saving you from expensive operations that would otherwise take longer than the network trip to the digital ocean box with memcached.

bravioz's avatar

Yes, I got it working. I want to improve landing page because there's lots of queries going on and many of the results are not changing that often.

bravioz's avatar

Another question with this. What would be a good way to measure time it takes to connect to the server (Memcached) and get a response? I would like to know is it just slowing down the response time.

Please or to participate in this conversation.